Compare commits
1 Commits
3c80ac3125
...
retheme
Author | SHA1 | Date | |
---|---|---|---|
bc0a036aea |
63
package-lock.json
generated
63
package-lock.json
generated
@ -26,9 +26,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"@hibas123/theme": {
|
"@hibas123/theme": {
|
||||||
"version": "1.0.5",
|
"version": "1.0.6",
|
||||||
"resolved": "https://registry.npmjs.org/@hibas123/theme/-/theme-1.0.5.tgz",
|
"resolved": "https://registry.npmjs.org/@hibas123/theme/-/theme-1.0.6.tgz",
|
||||||
"integrity": "sha512-D3qZVNz/lVKVh9olarxPyae0QF47OZCChVt6waRCr5j01zrLk/P7EVzM0Gzw8wf39LXVZTc63XbUm3whwKcutQ==",
|
"integrity": "sha512-NRODYM8714IlqE6DQKLunfNi/8uspKYrEtDH/bBeYQmYqCUYWRYIWGqQn05ym97GVRQW+6lrYzF6Ik4LqXojfQ==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"sass": "^1.21.0"
|
"sass": "^1.21.0"
|
||||||
}
|
}
|
||||||
@ -38,6 +38,21 @@
|
|||||||
"resolved": "https://registry.npmjs.org/@hibas123/utils/-/utils-2.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/@hibas123/utils/-/utils-2.1.0.tgz",
|
||||||
"integrity": "sha512-rS0SMENN7ta6pv9bNmIls8lvEOHbbDQXpiDI3u3z0Vx8B43ngEmEXbu5vKBA58ekYLr1WdHH6iIiySDChoi/RQ=="
|
"integrity": "sha512-rS0SMENN7ta6pv9bNmIls8lvEOHbbDQXpiDI3u3z0Vx8B43ngEmEXbu5vKBA58ekYLr1WdHH6iIiySDChoi/RQ=="
|
||||||
},
|
},
|
||||||
|
"@types/codemirror": {
|
||||||
|
"version": "0.0.76",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/codemirror/-/codemirror-0.0.76.tgz",
|
||||||
|
"integrity": "sha512-k/hpUb+Ebyn9z63qM8IbsRiW0eYHZ+pi/1e2reGzBKAZJzkjWmNTXXqLLiNv5d9ekyxkajxRBr5Hu2WZq/nokw==",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"@types/tern": "*"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"@types/estree": {
|
||||||
|
"version": "0.0.39",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/estree/-/estree-0.0.39.tgz",
|
||||||
|
"integrity": "sha512-EYNwp3bU+98cpU4lAWYYL7Zz+2gryWH1qbdDTidVd6hkiR6weksdbMadyXKXNPEkQFhXM+hVO9ZygomHXp+AIw==",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
"@types/events": {
|
"@types/events": {
|
||||||
"version": "3.0.0",
|
"version": "3.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/@types/events/-/events-3.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/@types/events/-/events-3.0.0.tgz",
|
||||||
@ -97,6 +112,15 @@
|
|||||||
"integrity": "sha512-7EJYyKTL7tFR8+gDbB6Wwz/arpGa0Mywk1TJbNzKzHtzbwVmY4HR9WqS5VV7dsBUKQmPNr192jHr/VpBluj/hg==",
|
"integrity": "sha512-7EJYyKTL7tFR8+gDbB6Wwz/arpGa0Mywk1TJbNzKzHtzbwVmY4HR9WqS5VV7dsBUKQmPNr192jHr/VpBluj/hg==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
"@types/tern": {
|
||||||
|
"version": "0.23.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/tern/-/tern-0.23.3.tgz",
|
||||||
|
"integrity": "sha512-imDtS4TAoTcXk0g7u4kkWqedB3E4qpjXzCpD2LU5M5NAXHzCDsypyvXSaG7mM8DKYkCRa7tFp4tS/lp/Wo7Q3w==",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"@types/estree": "*"
|
||||||
|
}
|
||||||
|
},
|
||||||
"@types/uikit": {
|
"@types/uikit": {
|
||||||
"version": "2.27.7",
|
"version": "2.27.7",
|
||||||
"resolved": "https://registry.npmjs.org/@types/uikit/-/uikit-2.27.7.tgz",
|
"resolved": "https://registry.npmjs.org/@types/uikit/-/uikit-2.27.7.tgz",
|
||||||
@ -1173,6 +1197,19 @@
|
|||||||
"integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=",
|
"integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
"codemirror": {
|
||||||
|
"version": "5.48.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/codemirror/-/codemirror-5.48.0.tgz",
|
||||||
|
"integrity": "sha512-3Ter+tYtRlTNtxtYdYNPxGxBL/b3cMcvPdPm70gvmcOO2Rauv/fUEewWa0tT596Hosv6ea2mtpx28OXBy1mQCg=="
|
||||||
|
},
|
||||||
|
"codemirror-spell-checker": {
|
||||||
|
"version": "1.1.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/codemirror-spell-checker/-/codemirror-spell-checker-1.1.2.tgz",
|
||||||
|
"integrity": "sha1-HGYPkIlIPMtRE7m6nKGcP0mTNx4=",
|
||||||
|
"requires": {
|
||||||
|
"typo-js": "*"
|
||||||
|
}
|
||||||
|
},
|
||||||
"collection-visit": {
|
"collection-visit": {
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/collection-visit/-/collection-visit-1.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/collection-visit/-/collection-visit-1.0.0.tgz",
|
||||||
@ -1855,6 +1892,16 @@
|
|||||||
"stream-shift": "^1.0.0"
|
"stream-shift": "^1.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"easymde": {
|
||||||
|
"version": "2.6.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/easymde/-/easymde-2.6.1.tgz",
|
||||||
|
"integrity": "sha512-DNdAn7xADNJBGQSULncZJXOlHSyK1IqvOPIaFOSKv18GBKItuCFy/f6KEUhFx47MDLQpWgznJgfvh9VKjavzaQ==",
|
||||||
|
"requires": {
|
||||||
|
"codemirror": "^5.47.0",
|
||||||
|
"codemirror-spell-checker": "1.1.2",
|
||||||
|
"marked": "^0.6.2"
|
||||||
|
}
|
||||||
|
},
|
||||||
"ecc-jsbn": {
|
"ecc-jsbn": {
|
||||||
"version": "0.1.2",
|
"version": "0.1.2",
|
||||||
"resolved": "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.2.tgz",
|
"resolved": "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.2.tgz",
|
||||||
@ -4170,6 +4217,11 @@
|
|||||||
"object-visit": "^1.0.0"
|
"object-visit": "^1.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"marked": {
|
||||||
|
"version": "0.6.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/marked/-/marked-0.6.3.tgz",
|
||||||
|
"integrity": "sha512-Fqa7eq+UaxfMriqzYLayfqAE40WN03jf+zHjT18/uXNuzjq3TY0XTbrAoPeqSJrAmPz11VuUA+kBPYOhHt9oOQ=="
|
||||||
|
},
|
||||||
"md5.js": {
|
"md5.js": {
|
||||||
"version": "1.3.5",
|
"version": "1.3.5",
|
||||||
"resolved": "https://registry.npmjs.org/md5.js/-/md5.js-1.3.5.tgz",
|
"resolved": "https://registry.npmjs.org/md5.js/-/md5.js-1.3.5.tgz",
|
||||||
@ -7003,6 +7055,11 @@
|
|||||||
"integrity": "sha512-7KxJovlYhTX5RaRbUdkAXN1KUZ8PwWlTzQdHV6xNqvuFOs7+WBo10TQUqT19Q/Jz2hk5v9TQDIhyLhhJY4p5AA==",
|
"integrity": "sha512-7KxJovlYhTX5RaRbUdkAXN1KUZ8PwWlTzQdHV6xNqvuFOs7+WBo10TQUqT19Q/Jz2hk5v9TQDIhyLhhJY4p5AA==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
"typo-js": {
|
||||||
|
"version": "1.0.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/typo-js/-/typo-js-1.0.3.tgz",
|
||||||
|
"integrity": "sha1-VNjrx5SfGngQkItgAsaEFSbJnVo="
|
||||||
|
},
|
||||||
"ua-parser-js": {
|
"ua-parser-js": {
|
||||||
"version": "0.7.19",
|
"version": "0.7.19",
|
||||||
"resolved": "https://registry.npmjs.org/ua-parser-js/-/ua-parser-js-0.7.19.tgz",
|
"resolved": "https://registry.npmjs.org/ua-parser-js/-/ua-parser-js-0.7.19.tgz",
|
||||||
|
@ -14,9 +14,10 @@
|
|||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@hibas123/secure-file-wrapper": "^2.5.0",
|
"@hibas123/secure-file-wrapper": "^2.5.0",
|
||||||
"@hibas123/theme": "^1.0.5",
|
"@hibas123/theme": "^1.0.6",
|
||||||
"@hibas123/utils": "^2.1.0",
|
"@hibas123/utils": "^2.1.0",
|
||||||
"aes-js": "^3.1.2",
|
"aes-js": "^3.1.2",
|
||||||
|
"easymde": "^2.6.1",
|
||||||
"feather-icons": "^4.22.1",
|
"feather-icons": "^4.22.1",
|
||||||
"idb": "^4.0.3",
|
"idb": "^4.0.3",
|
||||||
"js-sha256": "^0.9.0",
|
"js-sha256": "^0.9.0",
|
||||||
@ -25,6 +26,7 @@
|
|||||||
"uuid": "^3.3.2"
|
"uuid": "^3.3.2"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@types/codemirror": "0.0.76",
|
||||||
"@types/lodash.clonedeep": "^4.5.6",
|
"@types/lodash.clonedeep": "^4.5.6",
|
||||||
"@types/uikit": "^2.27.7",
|
"@types/uikit": "^2.27.7",
|
||||||
"@types/uuid": "^3.4.5",
|
"@types/uuid": "^3.4.5",
|
||||||
|
@ -4,76 +4,69 @@ import Refresh from "feather-icons/dist/icons/refresh-cw.svg";
|
|||||||
import "./footer.scss";
|
import "./footer.scss";
|
||||||
import Notifications from "../notifications";
|
import Notifications from "../notifications";
|
||||||
|
|
||||||
export class Footer extends Component<
|
export class Footer extends Component<{}, { synced: boolean, syncing: boolean }> {
|
||||||
{},
|
constructor(props) {
|
||||||
{ synced: boolean; syncing: boolean }
|
super(props);
|
||||||
> {
|
this.state = { synced: false, syncing: false };
|
||||||
constructor(props) {
|
this.onSyncedChange = this.onSyncedChange.bind(this);
|
||||||
super(props);
|
this.onSyncChange = this.onSyncChange.bind(this);
|
||||||
this.state = { synced: false, syncing: false };
|
}
|
||||||
this.onSyncedChange = this.onSyncedChange.bind(this);
|
|
||||||
this.onSyncChange = this.onSyncChange.bind(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
async componentWillMount() {
|
async componentWillMount() {
|
||||||
Notes.syncedObservable.subscribe(this.onSyncedChange);
|
Notes.syncedObservable.subscribe(this.onSyncedChange);
|
||||||
Notes.syncObservable.subscribe(this.onSyncChange);
|
Notes.syncObservable.subscribe(this.onSyncChange);
|
||||||
this.setState({ synced: await Notes.isSynced() });
|
this.setState({ synced: await Notes.isSynced() })
|
||||||
}
|
}
|
||||||
|
|
||||||
componentWillUnmount() {
|
componentWillUnmount() {
|
||||||
Notes.syncedObservable.unsubscribe(this.onSyncedChange);
|
Notes.syncedObservable.unsubscribe(this.onSyncedChange);
|
||||||
Notes.syncObservable.unsubscribe(this.onSyncChange);
|
Notes.syncObservable.unsubscribe(this.onSyncChange);
|
||||||
}
|
}
|
||||||
|
|
||||||
onSyncChange(state: boolean) {
|
onSyncChange(state: boolean) {
|
||||||
console.log("sync", state);
|
console.log("sync", state);
|
||||||
this.setState({ syncing: state });
|
this.setState({ syncing: state })
|
||||||
}
|
}
|
||||||
|
|
||||||
onSyncedChange(state: boolean) {
|
onSyncedChange(state: boolean) {
|
||||||
console.log("synced", state);
|
console.log("synced", state);
|
||||||
this.setState({ synced: state });
|
this.setState({ synced: state })
|
||||||
}
|
}
|
||||||
|
|
||||||
onSyncClick() {
|
onSyncClick() {
|
||||||
Notes.sync().then(() => {
|
Notes.sync().then(() => {
|
||||||
Notifications.sendInfo("Finished Synchronisation");
|
Notifications.sendInfo("Finished Synchronisation");
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
let extrac = undefined;
|
let extrac = undefined;
|
||||||
let color;
|
let color;
|
||||||
let text;
|
let text;
|
||||||
if (this.state.syncing) {
|
if (this.state.syncing) {
|
||||||
color = "orange";
|
color = "orange";
|
||||||
text = "syncing";
|
text = "syncing";
|
||||||
extrac = "reloading";
|
extrac = "reloading"
|
||||||
} else {
|
} else {
|
||||||
if (this.state.synced) {
|
if (this.state.synced) {
|
||||||
color = "green";
|
color = "green";
|
||||||
text = "synced";
|
text = "synced";
|
||||||
} else {
|
} else {
|
||||||
color = "red";
|
color = "red";
|
||||||
text = "not synced";
|
text = "not synced";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return (
|
return <footer class="elv-8" style="line-height: 1.1rem;">
|
||||||
<footer class="elv-8">
|
|
||||||
<span>
|
<span>
|
||||||
<span class={extrac}>
|
<span><a class={extrac} onClick={() => this.onSyncClick()} ><Refresh style="height: 1.1em; width: 1.1em;"></Refresh></a></span>
|
||||||
<a onClick={() => this.onSyncClick()}>
|
<span style={"margin-left: 8px; color:" + color}>{text}</span>
|
||||||
<Refresh style="height: 1em; width: 1em;"></Refresh>
|
|
||||||
</a>
|
|
||||||
</span>
|
|
||||||
<span style={"margin-left: 8px; color:" + color}>{text}</span>
|
|
||||||
</span>
|
</span>
|
||||||
<span>
|
<span>
|
||||||
Welcome <b>{Notes.name}</b>
|
Welcome <b>{Notes.name}</b>
|
||||||
</span>
|
</span>
|
||||||
<span style="color: lightgrey;">v1.5</span>
|
<span style="color: lightgrey;">
|
||||||
</footer>
|
v1.4
|
||||||
);
|
</span>
|
||||||
}
|
</footer>
|
||||||
|
}
|
||||||
}
|
}
|
51
src/components/routes/vault/Editor.tsx
Normal file
51
src/components/routes/vault/Editor.tsx
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
import { Component, h } from "preact";
|
||||||
|
import * as EasyMDE from "easymde";
|
||||||
|
// import "./easymde.css";
|
||||||
|
// import "./dark.css";
|
||||||
|
import "easymde/dist/easymde.min.css";
|
||||||
|
// import "codemirror/theme/monokai.css";
|
||||||
|
|
||||||
|
export interface EditorProps {
|
||||||
|
value: string;
|
||||||
|
valueChange: (value: string) => void;
|
||||||
|
save: () => void;
|
||||||
|
exit: () => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default class Editor extends Component<EditorProps, {}> {
|
||||||
|
element: HTMLInputElement;
|
||||||
|
easymde: EasyMDE;
|
||||||
|
|
||||||
|
componentDidMount() {
|
||||||
|
if (this.easymde)
|
||||||
|
this.easymde.toTextArea();
|
||||||
|
|
||||||
|
this.easymde = new EasyMDE({
|
||||||
|
element: this.element,
|
||||||
|
initialValue: this.props.value,
|
||||||
|
autofocus: true,
|
||||||
|
spellChecker: false
|
||||||
|
// theme: "monokai"
|
||||||
|
// autoDownloadFontAwesome: true
|
||||||
|
})
|
||||||
|
|
||||||
|
this.easymde.codemirror.on("change", () => {
|
||||||
|
this.props.valueChange(this.easymde.value());
|
||||||
|
});
|
||||||
|
|
||||||
|
this.easymde.codemirror.addKeyMap({
|
||||||
|
"Ctrl-S": () => this.props.save(),
|
||||||
|
"Esc": () => this.props.exit()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
shouldComponentUpdate(props: EditorProps) {
|
||||||
|
if (this.easymde.value() !== props.value)
|
||||||
|
this.easymde.value(props.value);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
render() {
|
||||||
|
return <textarea ref={ta => this.element = ta}></textarea>
|
||||||
|
}
|
||||||
|
}
|
188
src/components/routes/vault/Entry.1.tsx.old
Executable file
188
src/components/routes/vault/Entry.1.tsx.old
Executable file
@ -0,0 +1,188 @@
|
|||||||
|
import { h, Component } from "preact"
|
||||||
|
import { IVault, ViewNote } from "../../../notes";
|
||||||
|
import Trash from "feather-icons/dist/icons/trash-2.svg"
|
||||||
|
import X from "feather-icons/dist/icons/x.svg"
|
||||||
|
import Save from "feather-icons/dist/icons/save.svg"
|
||||||
|
|
||||||
|
import Navigation from "../../../navigation";
|
||||||
|
import { YesNoModal } from "../../modals/YesNoModal";
|
||||||
|
import Notifications, { MessageType } from "../../../notifications";
|
||||||
|
|
||||||
|
const minRows = 3;
|
||||||
|
export default class EntryComponent extends Component<{ vault: Promise<IVault>, id: string | undefined, note: string | undefined }, { title: string, changed: boolean }> {
|
||||||
|
private text: string = "";
|
||||||
|
private vault: IVault;
|
||||||
|
// private lineHeight: number = 24;
|
||||||
|
private note: ViewNote;
|
||||||
|
|
||||||
|
private rows: number = minRows;
|
||||||
|
|
||||||
|
private skip_save: boolean = false;
|
||||||
|
|
||||||
|
private inputElm: HTMLInputElement;
|
||||||
|
|
||||||
|
constructor(props) {
|
||||||
|
super(props);
|
||||||
|
this.state = { changed: false, title: "" };
|
||||||
|
this.textAreaChange = this.textAreaChange.bind(this);
|
||||||
|
this.textAreaKeyPress = this.textAreaKeyPress.bind(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
private toVault() {
|
||||||
|
history.back();
|
||||||
|
}
|
||||||
|
|
||||||
|
componentDidMount() {
|
||||||
|
this.inputElm.focus();
|
||||||
|
}
|
||||||
|
|
||||||
|
async componentWillMount() {
|
||||||
|
this.text = "";
|
||||||
|
this.vault = undefined;
|
||||||
|
this.note = undefined;
|
||||||
|
this.rows = minRows;
|
||||||
|
this.skip_save = false;
|
||||||
|
this.setState({ changed: false, title: "" });
|
||||||
|
try {
|
||||||
|
this.skip_save = false;
|
||||||
|
|
||||||
|
this.vault = await this.props.vault;
|
||||||
|
let note: ViewNote;
|
||||||
|
let changed = false;
|
||||||
|
if (this.props.id)
|
||||||
|
note = await this.vault.getNote(this.props.id)
|
||||||
|
else {
|
||||||
|
note = this.vault.newNote();
|
||||||
|
if (this.props.note) {
|
||||||
|
note.__value = this.props.note;
|
||||||
|
changed = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!note) {
|
||||||
|
Notifications.sendNotification("Note not found!", MessageType.ERROR);
|
||||||
|
} else {
|
||||||
|
this.note = note;
|
||||||
|
this.text = note.__value;
|
||||||
|
let rows = this.getRows(this.text);
|
||||||
|
if (rows !== this.rows) {
|
||||||
|
this.rows = rows;
|
||||||
|
}
|
||||||
|
let [title] = this.text.split("\n", 1);
|
||||||
|
this.setState({ title, changed })
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
Notifications.sendError(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async save() {
|
||||||
|
try {
|
||||||
|
if (this.state.changed) {
|
||||||
|
this.note.__value = this.text;
|
||||||
|
await this.vault.saveNote(this.note);
|
||||||
|
this.setState({ changed: false })
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
Notifications.sendError(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
componentWillUnmount() {
|
||||||
|
if (!this.skip_save)
|
||||||
|
this.save()
|
||||||
|
}
|
||||||
|
|
||||||
|
strToNr(value: string) {
|
||||||
|
let match = value.match(/\d/g)
|
||||||
|
return Number(match.join(""))
|
||||||
|
}
|
||||||
|
|
||||||
|
getRows(value: string) {
|
||||||
|
const lines = (value.match(/\r?\n/g) || '').length + 1
|
||||||
|
return Math.max(lines + 1, minRows);
|
||||||
|
}
|
||||||
|
|
||||||
|
textAreaChange(evt: KeyboardEvent) {
|
||||||
|
if (evt.keyCode === 17 || evt.keyCode === 27) return; //No character, so not relevant for this function
|
||||||
|
if (!this.state.changed && this.textAreaKeyPress(evt)) this.setState({ changed: true })
|
||||||
|
|
||||||
|
let target = (evt.target as HTMLTextAreaElement)
|
||||||
|
let value = target.value;
|
||||||
|
|
||||||
|
this.text = value;
|
||||||
|
|
||||||
|
let [title] = value.split("\n", 1);
|
||||||
|
if (title !== this.state.title)
|
||||||
|
this.setState({ title });
|
||||||
|
|
||||||
|
let rows = this.getRows(value);
|
||||||
|
if (rows !== this.rows) {
|
||||||
|
target.rows = rows;
|
||||||
|
this.rows = rows;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async exitHandler() {
|
||||||
|
if (this.state.changed) {
|
||||||
|
let modal = new YesNoModal("Really want to quit?");
|
||||||
|
let res = await modal.getResult();
|
||||||
|
if (res === true) {
|
||||||
|
this.skip_save = true;
|
||||||
|
this.toVault();
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
this.toVault()
|
||||||
|
}
|
||||||
|
|
||||||
|
textAreaKeyPress(evt: KeyboardEvent) {
|
||||||
|
console.log(evt);
|
||||||
|
if ((evt.keyCode === 83 || evt.keyCode === 13) && evt.ctrlKey) {
|
||||||
|
evt.preventDefault()
|
||||||
|
this.save();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else if (evt.keyCode === 27) {
|
||||||
|
evt.preventDefault();
|
||||||
|
this.exitHandler();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
render() {
|
||||||
|
const save_handler = async () => {
|
||||||
|
await this.save()
|
||||||
|
Navigation.setPage("/vault", { id: this.vault.id }, { entry: "false" }, true);
|
||||||
|
this.toVault()
|
||||||
|
}
|
||||||
|
|
||||||
|
const delete_handler = async () => {
|
||||||
|
await this.vault.deleteNote(this.props.id);
|
||||||
|
this.toVault()
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log("Rerender")
|
||||||
|
|
||||||
|
return <div>
|
||||||
|
<header class="header">
|
||||||
|
<a class="header-icon-button" onClick={() => this.exitHandler()}><X height={undefined} width={undefined} /></a>
|
||||||
|
{this.state.changed ? <a class="header-icon-button" style="margin-left: 0.5em;" onClick={() => save_handler()}><Save height={undefined} width={undefined} /></a> : undefined}
|
||||||
|
<h3 style="display:inline" class="button header-title">{this.state.title}</h3>
|
||||||
|
<a class="header-icon-button" onClick={() => delete_handler()}><Trash height={undefined} width={undefined} /></a>
|
||||||
|
</header>
|
||||||
|
<div class="container">
|
||||||
|
<textarea
|
||||||
|
value={this.text}
|
||||||
|
rows={this.rows}
|
||||||
|
class="inp"
|
||||||
|
style="width:100%;"
|
||||||
|
onInput={this.textAreaChange}
|
||||||
|
onKeyDown={this.textAreaKeyPress}
|
||||||
|
onChange={this.textAreaChange}
|
||||||
|
ref={elm => this.inputElm = elm}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
}
|
@ -7,6 +7,9 @@ import Save from "feather-icons/dist/icons/save.svg"
|
|||||||
import Navigation from "../../../navigation";
|
import Navigation from "../../../navigation";
|
||||||
import { YesNoModal } from "../../modals/YesNoModal";
|
import { YesNoModal } from "../../modals/YesNoModal";
|
||||||
import Notifications, { MessageType } from "../../../notifications";
|
import Notifications, { MessageType } from "../../../notifications";
|
||||||
|
import Theme from "../../../theme";
|
||||||
|
|
||||||
|
import Editor from "./Editor";
|
||||||
|
|
||||||
const minRows = 3;
|
const minRows = 3;
|
||||||
export default class EntryComponent extends Component<{ vault: Promise<IVault>, id: string | undefined, note: string | undefined }, { title: string, changed: boolean }> {
|
export default class EntryComponent extends Component<{ vault: Promise<IVault>, id: string | undefined, note: string | undefined }, { title: string, changed: boolean }> {
|
||||||
@ -15,37 +18,27 @@ export default class EntryComponent extends Component<{ vault: Promise<IVault>,
|
|||||||
// private lineHeight: number = 24;
|
// private lineHeight: number = 24;
|
||||||
private note: ViewNote;
|
private note: ViewNote;
|
||||||
|
|
||||||
private rows: number = minRows;
|
|
||||||
|
|
||||||
private skip_save: boolean = false;
|
private skip_save: boolean = false;
|
||||||
|
|
||||||
private inputElm: HTMLInputElement;
|
|
||||||
|
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
this.state = { changed: false, title: "" };
|
this.state = { changed: false, title: "" };
|
||||||
this.textAreaChange = this.textAreaChange.bind(this);
|
|
||||||
this.textAreaKeyPress = this.textAreaKeyPress.bind(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private toVault() {
|
private toVault() {
|
||||||
history.back();
|
history.back();
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() { }
|
||||||
this.inputElm.focus();
|
|
||||||
}
|
|
||||||
|
|
||||||
async componentWillMount() {
|
async componentWillMount() {
|
||||||
this.text = "";
|
this.text = "";
|
||||||
this.vault = undefined;
|
this.vault = undefined;
|
||||||
this.note = undefined;
|
this.note = undefined;
|
||||||
this.rows = minRows;
|
|
||||||
this.skip_save = false;
|
this.skip_save = false;
|
||||||
this.setState({ changed: false, title: "" });
|
this.setState({ changed: false, title: "" });
|
||||||
try {
|
try {
|
||||||
this.skip_save = false;
|
|
||||||
|
|
||||||
this.vault = await this.props.vault;
|
this.vault = await this.props.vault;
|
||||||
let note: ViewNote;
|
let note: ViewNote;
|
||||||
let changed = false;
|
let changed = false;
|
||||||
@ -64,10 +57,7 @@ export default class EntryComponent extends Component<{ vault: Promise<IVault>,
|
|||||||
} else {
|
} else {
|
||||||
this.note = note;
|
this.note = note;
|
||||||
this.text = note.__value;
|
this.text = note.__value;
|
||||||
let rows = this.getRows(this.text);
|
|
||||||
if (rows !== this.rows) {
|
|
||||||
this.rows = rows;
|
|
||||||
}
|
|
||||||
let [title] = this.text.split("\n", 1);
|
let [title] = this.text.split("\n", 1);
|
||||||
this.setState({ title, changed })
|
this.setState({ title, changed })
|
||||||
}
|
}
|
||||||
@ -93,37 +83,18 @@ export default class EntryComponent extends Component<{ vault: Promise<IVault>,
|
|||||||
this.save()
|
this.save()
|
||||||
}
|
}
|
||||||
|
|
||||||
strToNr(value: string) {
|
private textChange(value: string) {
|
||||||
let match = value.match(/\d/g)
|
if (!this.state.changed && value !== this.text)
|
||||||
return Number(match.join(""))
|
this.setState({ changed: true })
|
||||||
}
|
|
||||||
|
|
||||||
getRows(value: string) {
|
|
||||||
const lines = (value.match(/\r?\n/g) || '').length + 1
|
|
||||||
return Math.max(lines + 1, minRows);
|
|
||||||
}
|
|
||||||
|
|
||||||
textAreaChange(evt: KeyboardEvent) {
|
|
||||||
if (evt.keyCode === 17 || evt.keyCode === 27) return; //No character, so not relevant for this function
|
|
||||||
if (!this.state.changed && this.textAreaKeyPress(evt)) this.setState({ changed: true })
|
|
||||||
|
|
||||||
let target = (evt.target as HTMLTextAreaElement)
|
|
||||||
let value = target.value;
|
|
||||||
|
|
||||||
this.text = value;
|
this.text = value;
|
||||||
|
|
||||||
let [title] = value.split("\n", 1);
|
let [title] = value.split("\n", 1);
|
||||||
if (title !== this.state.title)
|
if (title !== this.state.title)
|
||||||
this.setState({ title });
|
this.setState({ title });
|
||||||
|
|
||||||
let rows = this.getRows(value);
|
|
||||||
if (rows !== this.rows) {
|
|
||||||
target.rows = rows;
|
|
||||||
this.rows = rows;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async exitHandler() {
|
private async exitHandler() {
|
||||||
if (this.state.changed) {
|
if (this.state.changed) {
|
||||||
let modal = new YesNoModal("Really want to quit?");
|
let modal = new YesNoModal("Really want to quit?");
|
||||||
let res = await modal.getResult();
|
let res = await modal.getResult();
|
||||||
@ -135,21 +106,6 @@ export default class EntryComponent extends Component<{ vault: Promise<IVault>,
|
|||||||
this.toVault()
|
this.toVault()
|
||||||
}
|
}
|
||||||
|
|
||||||
textAreaKeyPress(evt: KeyboardEvent) {
|
|
||||||
console.log(evt);
|
|
||||||
if ((evt.keyCode === 83 || evt.keyCode === 13) && evt.ctrlKey) {
|
|
||||||
evt.preventDefault()
|
|
||||||
this.save();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
else if (evt.keyCode === 27) {
|
|
||||||
evt.preventDefault();
|
|
||||||
this.exitHandler();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const save_handler = async () => {
|
const save_handler = async () => {
|
||||||
await this.save()
|
await this.save()
|
||||||
@ -171,17 +127,12 @@ export default class EntryComponent extends Component<{ vault: Promise<IVault>,
|
|||||||
<h3 style="display:inline" class="button header-title">{this.state.title}</h3>
|
<h3 style="display:inline" class="button header-title">{this.state.title}</h3>
|
||||||
<a class="header-icon-button" onClick={() => delete_handler()}><Trash height={undefined} width={undefined} /></a>
|
<a class="header-icon-button" onClick={() => delete_handler()}><Trash height={undefined} width={undefined} /></a>
|
||||||
</header>
|
</header>
|
||||||
<div class="container">
|
<div class="container" style={Theme.isDark() ? "filter: invert(100%);" : ""}>
|
||||||
<textarea
|
<Editor
|
||||||
value={this.text}
|
value={this.text}
|
||||||
rows={this.rows}
|
valueChange={value => this.textChange(value)}
|
||||||
class="inp"
|
save={() => this.save()}
|
||||||
style="width:100%;"
|
exit={() => this.exitHandler()} />
|
||||||
onInput={this.textAreaChange}
|
|
||||||
onKeyDown={this.textAreaKeyPress}
|
|
||||||
onChange={this.textAreaChange}
|
|
||||||
ref={elm => this.inputElm = elm}
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
|
858
src/components/routes/vault/dark.css
Normal file
858
src/components/routes/vault/dark.css
Normal file
@ -0,0 +1,858 @@
|
|||||||
|
/* SimpleMDE Theme Dark v0.0.0 https://github.com/xcatliu/simplemde-theme-dark#readme */
|
||||||
|
|
||||||
|
@charset "UTF-8";
|
||||||
|
|
||||||
|
.CodeMirror-gutter-filler,
|
||||||
|
.CodeMirror-scrollbar-filler {
|
||||||
|
background-color: #fff
|
||||||
|
}
|
||||||
|
|
||||||
|
.CodeMirror-gutters {
|
||||||
|
border-right: 1px solid #ddd;
|
||||||
|
background-color: #f7f7f7;
|
||||||
|
white-space: nowrap
|
||||||
|
}
|
||||||
|
|
||||||
|
.CodeMirror-linenumber {
|
||||||
|
padding: 0 3px 0 5px;
|
||||||
|
min-width: 20px;
|
||||||
|
text-align: right;
|
||||||
|
color: #999;
|
||||||
|
white-space: nowrap
|
||||||
|
}
|
||||||
|
|
||||||
|
.CodeMirror-guttermarker {
|
||||||
|
color: #000
|
||||||
|
}
|
||||||
|
|
||||||
|
.CodeMirror-guttermarker-subtle {
|
||||||
|
color: #999
|
||||||
|
}
|
||||||
|
|
||||||
|
.CodeMirror-cursor {
|
||||||
|
border-left: 1px solid #000;
|
||||||
|
border-right: none;
|
||||||
|
width: 0
|
||||||
|
}
|
||||||
|
|
||||||
|
.CodeMirror div.CodeMirror-secondarycursor {
|
||||||
|
border-left: 1px solid silver
|
||||||
|
}
|
||||||
|
|
||||||
|
.cm-fat-cursor .CodeMirror-cursor {
|
||||||
|
width: auto;
|
||||||
|
border: 0 !important;
|
||||||
|
background: #7e7
|
||||||
|
}
|
||||||
|
|
||||||
|
.cm-fat-cursor div.CodeMirror-cursors {
|
||||||
|
z-index: 1
|
||||||
|
}
|
||||||
|
|
||||||
|
.cm-animate-fat-cursor {
|
||||||
|
width: auto;
|
||||||
|
border: 0;
|
||||||
|
-webkit-animation: blink 1.06s steps(1) infinite;
|
||||||
|
animation: blink 1.06s steps(1) infinite;
|
||||||
|
background-color: #7e7
|
||||||
|
}
|
||||||
|
|
||||||
|
@-webkit-keyframes blink {
|
||||||
|
50% {
|
||||||
|
background-color: transparent
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes blink {
|
||||||
|
50% {
|
||||||
|
background-color: transparent
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.cm-tab {
|
||||||
|
display: inline-block;
|
||||||
|
text-decoration: inherit
|
||||||
|
}
|
||||||
|
|
||||||
|
.CodeMirror-rulers {
|
||||||
|
position: absolute;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
top: -50px;
|
||||||
|
bottom: -20px;
|
||||||
|
overflow: hidden
|
||||||
|
}
|
||||||
|
|
||||||
|
.CodeMirror-ruler {
|
||||||
|
border-left: 1px solid #ccc;
|
||||||
|
top: 0;
|
||||||
|
bottom: 0;
|
||||||
|
position: absolute
|
||||||
|
}
|
||||||
|
|
||||||
|
.CodeMirror,
|
||||||
|
.CodeMirror-scroll {
|
||||||
|
position: relative;
|
||||||
|
min-height: 300px
|
||||||
|
}
|
||||||
|
|
||||||
|
.cm-s-default .cm-header {
|
||||||
|
color: #00f
|
||||||
|
}
|
||||||
|
|
||||||
|
.cm-s-default .cm-quote {
|
||||||
|
color: #090
|
||||||
|
}
|
||||||
|
|
||||||
|
.cm-negative {
|
||||||
|
color: #d44
|
||||||
|
}
|
||||||
|
|
||||||
|
.cm-positive {
|
||||||
|
color: #292
|
||||||
|
}
|
||||||
|
|
||||||
|
.cm-header,
|
||||||
|
.cm-strong {
|
||||||
|
font-weight: 700
|
||||||
|
}
|
||||||
|
|
||||||
|
.cm-em {
|
||||||
|
font-style: italic
|
||||||
|
}
|
||||||
|
|
||||||
|
.cm-link {
|
||||||
|
text-decoration: underline
|
||||||
|
}
|
||||||
|
|
||||||
|
.CodeMirror .CodeMirror-code .cm-strikethrough,
|
||||||
|
.cm-strikethrough {
|
||||||
|
text-decoration: line-through
|
||||||
|
}
|
||||||
|
|
||||||
|
.cm-s-default .cm-keyword {
|
||||||
|
color: #708
|
||||||
|
}
|
||||||
|
|
||||||
|
.cm-s-default .cm-atom {
|
||||||
|
color: #219
|
||||||
|
}
|
||||||
|
|
||||||
|
.cm-s-default .cm-number {
|
||||||
|
color: #164
|
||||||
|
}
|
||||||
|
|
||||||
|
.cm-s-default .cm-def {
|
||||||
|
color: #00f
|
||||||
|
}
|
||||||
|
|
||||||
|
.cm-s-default .cm-variable-2 {
|
||||||
|
color: #05a
|
||||||
|
}
|
||||||
|
|
||||||
|
.cm-s-default .cm-variable-3 {
|
||||||
|
color: #085
|
||||||
|
}
|
||||||
|
|
||||||
|
.cm-s-default .cm-comment {
|
||||||
|
color: #a50
|
||||||
|
}
|
||||||
|
|
||||||
|
.cm-s-default .cm-string {
|
||||||
|
color: #a11
|
||||||
|
}
|
||||||
|
|
||||||
|
.cm-s-default .cm-string-2 {
|
||||||
|
color: #f50
|
||||||
|
}
|
||||||
|
|
||||||
|
.cm-s-default .cm-meta,
|
||||||
|
.cm-s-default .cm-qualifier {
|
||||||
|
color: #555
|
||||||
|
}
|
||||||
|
|
||||||
|
.cm-s-default .cm-builtin {
|
||||||
|
color: #30a
|
||||||
|
}
|
||||||
|
|
||||||
|
.cm-s-default .cm-bracket {
|
||||||
|
color: #997
|
||||||
|
}
|
||||||
|
|
||||||
|
.cm-s-default .cm-tag {
|
||||||
|
color: #170
|
||||||
|
}
|
||||||
|
|
||||||
|
.cm-s-default .cm-attribute {
|
||||||
|
color: #00c
|
||||||
|
}
|
||||||
|
|
||||||
|
.cm-s-default .cm-hr {
|
||||||
|
color: #999
|
||||||
|
}
|
||||||
|
|
||||||
|
.cm-s-default .cm-link {
|
||||||
|
color: #00c
|
||||||
|
}
|
||||||
|
|
||||||
|
.cm-invalidchar,
|
||||||
|
.cm-s-default .cm-error {
|
||||||
|
color: red
|
||||||
|
}
|
||||||
|
|
||||||
|
.CodeMirror-composing {
|
||||||
|
border-bottom: 2px solid
|
||||||
|
}
|
||||||
|
|
||||||
|
div.CodeMirror span.CodeMirror-matchingbracket {
|
||||||
|
color: #0f0
|
||||||
|
}
|
||||||
|
|
||||||
|
div.CodeMirror span.CodeMirror-nonmatchingbracket {
|
||||||
|
color: #f22
|
||||||
|
}
|
||||||
|
|
||||||
|
.CodeMirror-matchingtag {
|
||||||
|
background: rgba(255, 150, 0, .3)
|
||||||
|
}
|
||||||
|
|
||||||
|
.CodeMirror-activeline-background {
|
||||||
|
background: #e8f2ff
|
||||||
|
}
|
||||||
|
|
||||||
|
.CodeMirror {
|
||||||
|
position: relative;
|
||||||
|
overflow: hidden;
|
||||||
|
background: #fff
|
||||||
|
}
|
||||||
|
|
||||||
|
.CodeMirror-scroll {
|
||||||
|
overflow: scroll !important;
|
||||||
|
height: 100%;
|
||||||
|
outline: 0;
|
||||||
|
position: relative
|
||||||
|
}
|
||||||
|
|
||||||
|
.CodeMirror-sizer {
|
||||||
|
position: relative;
|
||||||
|
border-right: 30px solid transparent
|
||||||
|
}
|
||||||
|
|
||||||
|
.CodeMirror-gutter-filler,
|
||||||
|
.CodeMirror-hscrollbar,
|
||||||
|
.CodeMirror-scrollbar-filler,
|
||||||
|
.CodeMirror-vscrollbar {
|
||||||
|
position: absolute;
|
||||||
|
z-index: 6;
|
||||||
|
display: none
|
||||||
|
}
|
||||||
|
|
||||||
|
.CodeMirror-vscrollbar {
|
||||||
|
right: 0;
|
||||||
|
top: 0;
|
||||||
|
overflow-x: hidden;
|
||||||
|
overflow-y: scroll
|
||||||
|
}
|
||||||
|
|
||||||
|
.CodeMirror-hscrollbar {
|
||||||
|
bottom: 0;
|
||||||
|
left: 0;
|
||||||
|
overflow-y: hidden;
|
||||||
|
overflow-x: scroll
|
||||||
|
}
|
||||||
|
|
||||||
|
.CodeMirror-scrollbar-filler {
|
||||||
|
right: 0;
|
||||||
|
bottom: 0
|
||||||
|
}
|
||||||
|
|
||||||
|
.CodeMirror-gutter-filler {
|
||||||
|
left: 0;
|
||||||
|
bottom: 0
|
||||||
|
}
|
||||||
|
|
||||||
|
.CodeMirror-gutters {
|
||||||
|
position: absolute;
|
||||||
|
left: 0;
|
||||||
|
top: 0;
|
||||||
|
min-height: 100%;
|
||||||
|
z-index: 3
|
||||||
|
}
|
||||||
|
|
||||||
|
.CodeMirror-gutter {
|
||||||
|
white-space: normal;
|
||||||
|
height: 100%;
|
||||||
|
display: inline-block;
|
||||||
|
vertical-align: top;
|
||||||
|
margin-bottom: -30px
|
||||||
|
}
|
||||||
|
|
||||||
|
.CodeMirror-gutter-wrapper {
|
||||||
|
position: absolute;
|
||||||
|
z-index: 4;
|
||||||
|
background: 0 0 !important;
|
||||||
|
border: none !important;
|
||||||
|
-webkit-user-select: none;
|
||||||
|
-moz-user-select: none;
|
||||||
|
-ms-user-select: none;
|
||||||
|
user-select: none
|
||||||
|
}
|
||||||
|
|
||||||
|
.CodeMirror-gutter-background {
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
bottom: 0;
|
||||||
|
z-index: 4
|
||||||
|
}
|
||||||
|
|
||||||
|
.CodeMirror-gutter-elt {
|
||||||
|
position: absolute;
|
||||||
|
cursor: default;
|
||||||
|
z-index: 4
|
||||||
|
}
|
||||||
|
|
||||||
|
.CodeMirror-lines {
|
||||||
|
cursor: text;
|
||||||
|
min-height: 1px
|
||||||
|
}
|
||||||
|
|
||||||
|
.CodeMirror pre {
|
||||||
|
border-radius: 0;
|
||||||
|
border-width: 0;
|
||||||
|
background: 0 0;
|
||||||
|
font-family: inherit;
|
||||||
|
font-size: inherit;
|
||||||
|
margin: 0;
|
||||||
|
white-space: pre;
|
||||||
|
word-wrap: normal;
|
||||||
|
line-height: inherit;
|
||||||
|
color: inherit;
|
||||||
|
z-index: 2;
|
||||||
|
position: relative;
|
||||||
|
overflow: visible;
|
||||||
|
-webkit-tap-highlight-color: transparent;
|
||||||
|
-webkit-font-variant-ligatures: contextual;
|
||||||
|
font-variant-ligatures: contextual
|
||||||
|
}
|
||||||
|
|
||||||
|
.CodeMirror-wrap pre {
|
||||||
|
word-wrap: break-word;
|
||||||
|
white-space: pre-wrap;
|
||||||
|
word-break: normal
|
||||||
|
}
|
||||||
|
|
||||||
|
.CodeMirror-linebackground {
|
||||||
|
position: absolute;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
top: 0;
|
||||||
|
bottom: 0;
|
||||||
|
z-index: 0
|
||||||
|
}
|
||||||
|
|
||||||
|
.CodeMirror-linewidget {
|
||||||
|
position: relative;
|
||||||
|
z-index: 2;
|
||||||
|
overflow: auto
|
||||||
|
}
|
||||||
|
|
||||||
|
.CodeMirror-code {
|
||||||
|
outline: 0
|
||||||
|
}
|
||||||
|
|
||||||
|
.CodeMirror-gutter,
|
||||||
|
.CodeMirror-gutters,
|
||||||
|
.CodeMirror-linenumber,
|
||||||
|
.CodeMirror-scroll,
|
||||||
|
.CodeMirror-sizer {
|
||||||
|
box-sizing: content-box
|
||||||
|
}
|
||||||
|
|
||||||
|
.CodeMirror-measure {
|
||||||
|
position: absolute;
|
||||||
|
width: 100%;
|
||||||
|
height: 0;
|
||||||
|
overflow: hidden;
|
||||||
|
visibility: hidden
|
||||||
|
}
|
||||||
|
|
||||||
|
.CodeMirror-cursor {
|
||||||
|
position: absolute;
|
||||||
|
pointer-events: none
|
||||||
|
}
|
||||||
|
|
||||||
|
.CodeMirror-measure pre {
|
||||||
|
position: static
|
||||||
|
}
|
||||||
|
|
||||||
|
div.CodeMirror-cursors {
|
||||||
|
visibility: hidden;
|
||||||
|
position: relative;
|
||||||
|
z-index: 3
|
||||||
|
}
|
||||||
|
|
||||||
|
.CodeMirror-focused div.CodeMirror-cursors,
|
||||||
|
div.CodeMirror-dragcursors {
|
||||||
|
visibility: visible
|
||||||
|
}
|
||||||
|
|
||||||
|
.CodeMirror-selected {
|
||||||
|
background: #d9d9d9
|
||||||
|
}
|
||||||
|
|
||||||
|
.CodeMirror-focused .CodeMirror-selected {
|
||||||
|
background: #d7d4f0
|
||||||
|
}
|
||||||
|
|
||||||
|
.CodeMirror-crosshair {
|
||||||
|
cursor: crosshair
|
||||||
|
}
|
||||||
|
|
||||||
|
.CodeMirror-line::selection,
|
||||||
|
.CodeMirror-line>span::selection,
|
||||||
|
.CodeMirror-line>span>span::selection {
|
||||||
|
background: #d7d4f0
|
||||||
|
}
|
||||||
|
|
||||||
|
.CodeMirror-line::-moz-selection,
|
||||||
|
.CodeMirror-line>span::-moz-selection,
|
||||||
|
.CodeMirror-line>span>span::-moz-selection {
|
||||||
|
background: #d7d4f0
|
||||||
|
}
|
||||||
|
|
||||||
|
.cm-searching {
|
||||||
|
background: #ffa;
|
||||||
|
background: rgba(255, 255, 0, .4)
|
||||||
|
}
|
||||||
|
|
||||||
|
.cm-force-border {
|
||||||
|
padding-right: .1px
|
||||||
|
}
|
||||||
|
|
||||||
|
@media print {
|
||||||
|
.CodeMirror div.CodeMirror-cursors {
|
||||||
|
visibility: hidden
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.cm-tab-wrap-hack:after {
|
||||||
|
content: ''
|
||||||
|
}
|
||||||
|
|
||||||
|
span.CodeMirror-selectedtext {
|
||||||
|
background: 0 0
|
||||||
|
}
|
||||||
|
|
||||||
|
.CodeMirror {
|
||||||
|
background-color: #444;
|
||||||
|
border: 1px solid #555;
|
||||||
|
border-bottom-left-radius: 3px;
|
||||||
|
border-bottom-right-radius: 3px;
|
||||||
|
color: #aaa;
|
||||||
|
font-family: inherit;
|
||||||
|
font-size: 18px;
|
||||||
|
height: auto;
|
||||||
|
line-height: 1.5;
|
||||||
|
padding: 14px;
|
||||||
|
z-index: 1
|
||||||
|
}
|
||||||
|
|
||||||
|
.CodeMirror-scroll {
|
||||||
|
margin-bottom: -32px;
|
||||||
|
margin-right: -32px;
|
||||||
|
padding-bottom: 32px
|
||||||
|
}
|
||||||
|
|
||||||
|
.CodeMirror-fullscreen {
|
||||||
|
background-color: #444;
|
||||||
|
border: 0;
|
||||||
|
border-top: 1px solid #555;
|
||||||
|
bottom: 0;
|
||||||
|
height: auto;
|
||||||
|
left: 0;
|
||||||
|
position: fixed !important;
|
||||||
|
right: 0;
|
||||||
|
top: 58px;
|
||||||
|
z-index: 9
|
||||||
|
}
|
||||||
|
|
||||||
|
.CodeMirror-sided {
|
||||||
|
width: 50% !important
|
||||||
|
}
|
||||||
|
|
||||||
|
.CodeMirror .CodeMirror-placeholder {
|
||||||
|
color: #777
|
||||||
|
}
|
||||||
|
|
||||||
|
.CodeMirror-cursor {
|
||||||
|
border-left-color: #aaa
|
||||||
|
}
|
||||||
|
|
||||||
|
.CodeMirror pre,
|
||||||
|
.CodeMirror-lines {
|
||||||
|
padding: 0
|
||||||
|
}
|
||||||
|
|
||||||
|
.CodeMirror-focused .CodeMirror-selected,
|
||||||
|
.CodeMirror-line::-moz-selection,
|
||||||
|
.CodeMirror-line>span::-moz-selection,
|
||||||
|
.CodeMirror-line>span>span::-moz-selection,
|
||||||
|
.CodeMirror-selected {
|
||||||
|
background-color: rgba(255, 255, 255, .1)
|
||||||
|
}
|
||||||
|
|
||||||
|
.CodeMirror-focused .CodeMirror-selected,
|
||||||
|
.CodeMirror-line::selection,
|
||||||
|
.CodeMirror-line>span::selection,
|
||||||
|
.CodeMirror-line>span>span::selection,
|
||||||
|
.CodeMirror-selected {
|
||||||
|
background-color: rgba(255, 255, 255, .1)
|
||||||
|
}
|
||||||
|
|
||||||
|
.CodeMirror .CodeMirror-code .cm-attribute,
|
||||||
|
.CodeMirror .CodeMirror-code .cm-tag {
|
||||||
|
color: #95bf40
|
||||||
|
}
|
||||||
|
|
||||||
|
.CodeMirror .CodeMirror-code .cm-string {
|
||||||
|
color: #777
|
||||||
|
}
|
||||||
|
|
||||||
|
.CodeMirror .CodeMirror-code .cm-link {
|
||||||
|
color: #ffd500
|
||||||
|
}
|
||||||
|
|
||||||
|
.CodeMirror .CodeMirror-code .cm-formatting-code,
|
||||||
|
.CodeMirror .CodeMirror-code .cm-formatting-code-block,
|
||||||
|
.CodeMirror .CodeMirror-code .cm-formatting-em,
|
||||||
|
.CodeMirror .CodeMirror-code .cm-formatting-header,
|
||||||
|
.CodeMirror .CodeMirror-code .cm-formatting-strikethrough,
|
||||||
|
.CodeMirror .CodeMirror-code .cm-formatting-strong,
|
||||||
|
.CodeMirror .CodeMirror-code .cm-hr,
|
||||||
|
.CodeMirror .CodeMirror-code .cm-quote,
|
||||||
|
.CodeMirror .CodeMirror-code .cm-url {
|
||||||
|
color: #777
|
||||||
|
}
|
||||||
|
|
||||||
|
.CodeMirror .CodeMirror-code .cm-header-1,
|
||||||
|
.CodeMirror .CodeMirror-code .cm-header-2,
|
||||||
|
.CodeMirror .CodeMirror-code .cm-header-3,
|
||||||
|
.CodeMirror .CodeMirror-code .cm-header-4,
|
||||||
|
.CodeMirror .CodeMirror-code .cm-header-5,
|
||||||
|
.CodeMirror .CodeMirror-code .cm-header-6 {
|
||||||
|
line-height: 2
|
||||||
|
}
|
||||||
|
|
||||||
|
.CodeMirror .CodeMirror-code .cm-header-1 {
|
||||||
|
font-size: 32px
|
||||||
|
}
|
||||||
|
|
||||||
|
.CodeMirror .CodeMirror-code .cm-header-2 {
|
||||||
|
font-size: 26px
|
||||||
|
}
|
||||||
|
|
||||||
|
.CodeMirror .CodeMirror-code .cm-header-3 {
|
||||||
|
font-size: 24px
|
||||||
|
}
|
||||||
|
|
||||||
|
.CodeMirror .CodeMirror-code .cm-header-4 {
|
||||||
|
font-size: 22px
|
||||||
|
}
|
||||||
|
|
||||||
|
.CodeMirror .CodeMirror-code .cm-header-5 {
|
||||||
|
font-size: 20px
|
||||||
|
}
|
||||||
|
|
||||||
|
.CodeMirror .CodeMirror-code .cm-header-6 {
|
||||||
|
font-size: 18px
|
||||||
|
}
|
||||||
|
|
||||||
|
.CodeMirror .CodeMirror-code .cm-header,
|
||||||
|
.CodeMirror .CodeMirror-code .cm-strong {
|
||||||
|
font-weight: 600
|
||||||
|
}
|
||||||
|
|
||||||
|
.CodeMirror .CodeMirror-code .cm-comment {
|
||||||
|
background-color: rgba(255, 255, 255, .05);
|
||||||
|
font-family: Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
|
||||||
|
font-size: 14px;
|
||||||
|
padding: 6px 0 4px
|
||||||
|
}
|
||||||
|
|
||||||
|
.CodeMirror .CodeMirror-code span.CodeMirror-selectedtext.cm-comment {
|
||||||
|
background-color: rgba(255, 255, 255, .05)
|
||||||
|
}
|
||||||
|
|
||||||
|
.editor-preview {
|
||||||
|
height: 100%;
|
||||||
|
left: 0;
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
width: 100%;
|
||||||
|
z-index: 2
|
||||||
|
}
|
||||||
|
|
||||||
|
.editor-preview-side {
|
||||||
|
border: 0;
|
||||||
|
border-left: 1px solid #555;
|
||||||
|
border-top: 1px solid #555;
|
||||||
|
bottom: 0;
|
||||||
|
position: fixed;
|
||||||
|
right: 0;
|
||||||
|
top: 58px;
|
||||||
|
width: 50%;
|
||||||
|
z-index: 9
|
||||||
|
}
|
||||||
|
|
||||||
|
.editor-preview,
|
||||||
|
.editor-preview-side {
|
||||||
|
background-color: #444;
|
||||||
|
box-sizing: border-box;
|
||||||
|
color: #aaa;
|
||||||
|
display: none;
|
||||||
|
font-family: inherit;
|
||||||
|
font-size: 18px;
|
||||||
|
line-height: 1.5;
|
||||||
|
overflow: auto;
|
||||||
|
padding: 0 14px 14px
|
||||||
|
}
|
||||||
|
|
||||||
|
.editor-preview pre,
|
||||||
|
.editor-preview-side pre {
|
||||||
|
background-color: rgba(255, 255, 255, .05);
|
||||||
|
font-family: Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
|
||||||
|
font-size: 14px;
|
||||||
|
line-height: 1.2;
|
||||||
|
margin-top: 14px;
|
||||||
|
overflow: auto;
|
||||||
|
-webkit-overflow-scrolling: touch;
|
||||||
|
padding: 14px
|
||||||
|
}
|
||||||
|
|
||||||
|
.editor-preview pre code,
|
||||||
|
.editor-preview-side pre code {
|
||||||
|
background-color: transparent;
|
||||||
|
font-size: 14px;
|
||||||
|
padding: 0
|
||||||
|
}
|
||||||
|
|
||||||
|
.editor-preview-active,
|
||||||
|
.editor-preview-active-side {
|
||||||
|
display: block
|
||||||
|
}
|
||||||
|
|
||||||
|
.editor-preview table,
|
||||||
|
.editor-preview-side table {
|
||||||
|
background-color: #444;
|
||||||
|
border: 0;
|
||||||
|
border-collapse: collapse;
|
||||||
|
border-spacing: 0;
|
||||||
|
width: 100%
|
||||||
|
}
|
||||||
|
|
||||||
|
.editor-preview table caption,
|
||||||
|
.editor-preview-side table caption {
|
||||||
|
caption-side: bottom;
|
||||||
|
color: #777;
|
||||||
|
padding: 7px;
|
||||||
|
text-align: left
|
||||||
|
}
|
||||||
|
|
||||||
|
.editor-preview table td,
|
||||||
|
.editor-preview table th,
|
||||||
|
.editor-preview-side table td,
|
||||||
|
.editor-preview-side table th {
|
||||||
|
border: 0;
|
||||||
|
border-bottom: 1px solid #555;
|
||||||
|
padding: 7px;
|
||||||
|
text-align: left
|
||||||
|
}
|
||||||
|
|
||||||
|
.editor-preview table th,
|
||||||
|
.editor-preview-side table th {
|
||||||
|
background-color: rgba(255, 255, 255, .05);
|
||||||
|
font-weight: 600
|
||||||
|
}
|
||||||
|
|
||||||
|
.editor-preview audio:not([controls]),
|
||||||
|
.editor-preview-side audio:not([controls]) {
|
||||||
|
display: none;
|
||||||
|
height: 0
|
||||||
|
}
|
||||||
|
|
||||||
|
.editor-preview img,
|
||||||
|
.editor-preview-side img {
|
||||||
|
max-width: 100%;
|
||||||
|
vertical-align: middle
|
||||||
|
}
|
||||||
|
|
||||||
|
.editor-preview audio,
|
||||||
|
.editor-preview video,
|
||||||
|
.editor-preview-side audio,
|
||||||
|
.editor-preview-side video {
|
||||||
|
width: 100%
|
||||||
|
}
|
||||||
|
|
||||||
|
.editor-toolbar {
|
||||||
|
background-color: #444;
|
||||||
|
border: 1px solid #555;
|
||||||
|
border-bottom: 0;
|
||||||
|
border-top-left-radius: 3px;
|
||||||
|
border-top-right-radius: 3px;
|
||||||
|
font-size: 18px;
|
||||||
|
padding: 0 14px;
|
||||||
|
position: relative;
|
||||||
|
-webkit-user-select: none;
|
||||||
|
-moz-user-select: none;
|
||||||
|
-ms-user-select: none;
|
||||||
|
user-select: none
|
||||||
|
}
|
||||||
|
|
||||||
|
.editor-toolbar::after,
|
||||||
|
.editor-toolbar::before {
|
||||||
|
content: ' ';
|
||||||
|
display: block;
|
||||||
|
height: 1px
|
||||||
|
}
|
||||||
|
|
||||||
|
.editor-toolbar::before {
|
||||||
|
margin-bottom: 7px
|
||||||
|
}
|
||||||
|
|
||||||
|
.editor-toolbar::after {
|
||||||
|
margin-top: 7px
|
||||||
|
}
|
||||||
|
|
||||||
|
.editor-toolbar a {
|
||||||
|
border: 1px solid transparent;
|
||||||
|
border-radius: 3px;
|
||||||
|
color: #777 !important;
|
||||||
|
cursor: pointer;
|
||||||
|
display: inline-block;
|
||||||
|
font-size: 80%;
|
||||||
|
height: 30px;
|
||||||
|
margin: 0;
|
||||||
|
text-align: center;
|
||||||
|
text-decoration: none !important;
|
||||||
|
width: 30px
|
||||||
|
}
|
||||||
|
|
||||||
|
.editor-toolbar a.active,
|
||||||
|
.editor-toolbar a:hover {
|
||||||
|
border-color: #555;
|
||||||
|
color: #aaa !important
|
||||||
|
}
|
||||||
|
|
||||||
|
.editor-toolbar a::before {
|
||||||
|
line-height: 30px
|
||||||
|
}
|
||||||
|
|
||||||
|
.editor-toolbar a.fa-header-x::after {
|
||||||
|
bottom: -.25em;
|
||||||
|
font-family: inherit;
|
||||||
|
font-size: 80%;
|
||||||
|
line-height: 0;
|
||||||
|
position: relative;
|
||||||
|
vertical-align: baseline
|
||||||
|
}
|
||||||
|
|
||||||
|
.editor-toolbar a.fa-header-1::after {
|
||||||
|
content: "1"
|
||||||
|
}
|
||||||
|
|
||||||
|
.editor-toolbar a.fa-header-2::after {
|
||||||
|
content: "2"
|
||||||
|
}
|
||||||
|
|
||||||
|
.editor-toolbar a.fa-header-3::after {
|
||||||
|
content: "3"
|
||||||
|
}
|
||||||
|
|
||||||
|
.editor-toolbar a.fa-header-bigger::after {
|
||||||
|
content: "▲"
|
||||||
|
}
|
||||||
|
|
||||||
|
.editor-toolbar a.fa-header-smaller::after {
|
||||||
|
content: "▼"
|
||||||
|
}
|
||||||
|
|
||||||
|
.editor-toolbar i.separator {
|
||||||
|
border-right: 1px solid #555;
|
||||||
|
color: transparent;
|
||||||
|
display: inline-block;
|
||||||
|
margin: 0 7px;
|
||||||
|
text-indent: -10px;
|
||||||
|
width: 0
|
||||||
|
}
|
||||||
|
|
||||||
|
.editor-toolbar:hover a {
|
||||||
|
color: #aaa !important
|
||||||
|
}
|
||||||
|
|
||||||
|
.editor-toolbar.fullscreen {
|
||||||
|
background-color: #444;
|
||||||
|
border: 0;
|
||||||
|
box-sizing: border-box;
|
||||||
|
height: 58px;
|
||||||
|
left: 0;
|
||||||
|
overflow-x: auto;
|
||||||
|
overflow-y: hidden;
|
||||||
|
padding-bottom: 14px;
|
||||||
|
padding-top: 14px;
|
||||||
|
position: fixed;
|
||||||
|
top: 0;
|
||||||
|
white-space: nowrap;
|
||||||
|
width: 100%;
|
||||||
|
z-index: 9
|
||||||
|
}
|
||||||
|
|
||||||
|
.editor-toolbar.fullscreen::after,
|
||||||
|
.editor-toolbar.fullscreen::before {
|
||||||
|
height: 58px;
|
||||||
|
left: 0;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
position: fixed;
|
||||||
|
top: 0;
|
||||||
|
width: 20px
|
||||||
|
}
|
||||||
|
|
||||||
|
@media only screen and (max-width:700px) {
|
||||||
|
.editor-toolbar a.no-mobile {
|
||||||
|
display: none
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.editor-toolbar.disabled-for-preview a:not(.no-disable) {
|
||||||
|
background-color: #444;
|
||||||
|
border-color: transparent;
|
||||||
|
pointer-events: none;
|
||||||
|
text-shadow: inherit
|
||||||
|
}
|
||||||
|
|
||||||
|
.editor-statusbar {
|
||||||
|
color: #777;
|
||||||
|
font-family: inherit;
|
||||||
|
font-size: 80%;
|
||||||
|
padding: 7px 14px;
|
||||||
|
text-align: right
|
||||||
|
}
|
||||||
|
|
||||||
|
.editor-statusbar span {
|
||||||
|
display: inline-block;
|
||||||
|
margin-left: 1em
|
||||||
|
}
|
||||||
|
|
||||||
|
.editor-statusbar .lines::before {
|
||||||
|
content: 'lines: '
|
||||||
|
}
|
||||||
|
|
||||||
|
.editor-statusbar .words::before {
|
||||||
|
content: 'words: '
|
||||||
|
}
|
||||||
|
|
||||||
|
.editor-statusbar .characters::before {
|
||||||
|
content: 'characters: '
|
||||||
|
}
|
||||||
|
|
||||||
|
/*# sourceMappingURL=simplemde-theme-dark.min.css.map */
|
321
src/components/routes/vault/easymde.css
Normal file
321
src/components/routes/vault/easymde.css
Normal file
@ -0,0 +1,321 @@
|
|||||||
|
.CodeMirror {
|
||||||
|
box-sizing: border-box;
|
||||||
|
height: auto;
|
||||||
|
border: 1px solid #ddd;
|
||||||
|
border-bottom-left-radius: 4px;
|
||||||
|
border-bottom-right-radius: 4px;
|
||||||
|
padding: 10px;
|
||||||
|
font: inherit;
|
||||||
|
z-index: 1;
|
||||||
|
word-wrap: break-word;
|
||||||
|
}
|
||||||
|
|
||||||
|
.CodeMirror-scroll {
|
||||||
|
cursor: text;
|
||||||
|
}
|
||||||
|
|
||||||
|
.CodeMirror-fullscreen {
|
||||||
|
background: #fff;
|
||||||
|
position: fixed !important;
|
||||||
|
top: 50px;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
bottom: 0;
|
||||||
|
height: auto;
|
||||||
|
z-index: 9;
|
||||||
|
border-right: none !important;
|
||||||
|
border-bottom-right-radius: 0 !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.CodeMirror-sided {
|
||||||
|
width: 50% !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.CodeMirror-placeholder {
|
||||||
|
opacity: .5;
|
||||||
|
}
|
||||||
|
|
||||||
|
.CodeMirror-focused .CodeMirror-selected {
|
||||||
|
background: #d9d9d9;
|
||||||
|
}
|
||||||
|
|
||||||
|
.editor-toolbar {
|
||||||
|
position: relative;
|
||||||
|
-webkit-user-select: none;
|
||||||
|
-moz-user-select: none;
|
||||||
|
-ms-user-select: none;
|
||||||
|
-o-user-select: none;
|
||||||
|
user-select: none;
|
||||||
|
padding: 0 10px;
|
||||||
|
border-top: 1px solid #bbb;
|
||||||
|
border-left: 1px solid #bbb;
|
||||||
|
border-right: 1px solid #bbb;
|
||||||
|
border-top-left-radius: 4px;
|
||||||
|
border-top-right-radius: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.editor-toolbar:after,
|
||||||
|
.editor-toolbar:before {
|
||||||
|
display: block;
|
||||||
|
content: ' ';
|
||||||
|
height: 1px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.editor-toolbar:before {
|
||||||
|
margin-bottom: 8px
|
||||||
|
}
|
||||||
|
|
||||||
|
.editor-toolbar:after {
|
||||||
|
margin-top: 8px
|
||||||
|
}
|
||||||
|
|
||||||
|
.editor-toolbar.fullscreen {
|
||||||
|
width: 100%;
|
||||||
|
height: 50px;
|
||||||
|
overflow-x: auto;
|
||||||
|
overflow-y: hidden;
|
||||||
|
white-space: nowrap;
|
||||||
|
padding-top: 10px;
|
||||||
|
padding-bottom: 10px;
|
||||||
|
box-sizing: border-box;
|
||||||
|
background: #fff;
|
||||||
|
border: 0;
|
||||||
|
position: fixed;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
opacity: 1;
|
||||||
|
z-index: 9;
|
||||||
|
}
|
||||||
|
|
||||||
|
.editor-toolbar.fullscreen::before {
|
||||||
|
width: 20px;
|
||||||
|
height: 50px;
|
||||||
|
background: -moz-linear-gradient(left, rgba(255, 255, 255, 1) 0%, rgba(255, 255, 255, 0) 100%);
|
||||||
|
background: -webkit-gradient(linear, left top, right top, color-stop(0%, rgba(255, 255, 255, 1)), color-stop(100%, rgba(255, 255, 255, 0)));
|
||||||
|
background: -webkit-linear-gradient(left, rgba(255, 255, 255, 1) 0%, rgba(255, 255, 255, 0) 100%);
|
||||||
|
background: -o-linear-gradient(left, rgba(255, 255, 255, 1) 0%, rgba(255, 255, 255, 0) 100%);
|
||||||
|
background: -ms-linear-gradient(left, rgba(255, 255, 255, 1) 0%, rgba(255, 255, 255, 0) 100%);
|
||||||
|
background: linear-gradient(to right, rgba(255, 255, 255, 1) 0%, rgba(255, 255, 255, 0) 100%);
|
||||||
|
position: fixed;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.editor-toolbar.fullscreen::after {
|
||||||
|
width: 20px;
|
||||||
|
height: 50px;
|
||||||
|
background: -moz-linear-gradient(left, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 1) 100%);
|
||||||
|
background: -webkit-gradient(linear, left top, right top, color-stop(0%, rgba(255, 255, 255, 0)), color-stop(100%, rgba(255, 255, 255, 1)));
|
||||||
|
background: -webkit-linear-gradient(left, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 1) 100%);
|
||||||
|
background: -o-linear-gradient(left, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 1) 100%);
|
||||||
|
background: -ms-linear-gradient(left, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 1) 100%);
|
||||||
|
background: linear-gradient(to right, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 1) 100%);
|
||||||
|
position: fixed;
|
||||||
|
top: 0;
|
||||||
|
right: 0;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.editor-toolbar button {
|
||||||
|
background: transparent;
|
||||||
|
display: inline-block;
|
||||||
|
text-align: center;
|
||||||
|
text-decoration: none !important;
|
||||||
|
width: 30px;
|
||||||
|
height: 30px;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
border: 1px solid transparent;
|
||||||
|
border-radius: 3px;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.editor-toolbar button.active,
|
||||||
|
.editor-toolbar button:hover {
|
||||||
|
background: #fcfcfc;
|
||||||
|
border-color: #95a5a6;
|
||||||
|
}
|
||||||
|
|
||||||
|
.editor-toolbar i.separator {
|
||||||
|
display: inline-block;
|
||||||
|
width: 0;
|
||||||
|
border-left: 1px solid #d9d9d9;
|
||||||
|
border-right: 1px solid #fff;
|
||||||
|
color: transparent;
|
||||||
|
text-indent: -10px;
|
||||||
|
margin: 0 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.editor-toolbar button:after {
|
||||||
|
font-family: Arial, "Helvetica Neue", Helvetica, sans-serif;
|
||||||
|
font-size: 65%;
|
||||||
|
vertical-align: text-bottom;
|
||||||
|
position: relative;
|
||||||
|
top: 2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.editor-toolbar button.heading-1:after {
|
||||||
|
content: "1";
|
||||||
|
}
|
||||||
|
|
||||||
|
.editor-toolbar button.heading-2:after {
|
||||||
|
content: "2";
|
||||||
|
}
|
||||||
|
|
||||||
|
.editor-toolbar button.heading-3:after {
|
||||||
|
content: "3";
|
||||||
|
}
|
||||||
|
|
||||||
|
.editor-toolbar button.heading-bigger:after {
|
||||||
|
content: "▲";
|
||||||
|
}
|
||||||
|
|
||||||
|
.editor-toolbar button.heading-smaller:after {
|
||||||
|
content: "▼";
|
||||||
|
}
|
||||||
|
|
||||||
|
.editor-toolbar.disabled-for-preview button:not(.no-disable) {
|
||||||
|
opacity: .6;
|
||||||
|
pointer-events: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media only screen and (max-width: 700px) {
|
||||||
|
.editor-toolbar i.no-mobile {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.editor-statusbar {
|
||||||
|
padding: 8px 10px;
|
||||||
|
font-size: 12px;
|
||||||
|
color: #959694;
|
||||||
|
text-align: right;
|
||||||
|
}
|
||||||
|
|
||||||
|
.editor-statusbar span {
|
||||||
|
display: inline-block;
|
||||||
|
min-width: 4em;
|
||||||
|
margin-left: 1em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.editor-statusbar .lines:before {
|
||||||
|
content: 'lines: '
|
||||||
|
}
|
||||||
|
|
||||||
|
.editor-statusbar .words:before {
|
||||||
|
content: 'words: '
|
||||||
|
}
|
||||||
|
|
||||||
|
.editor-statusbar .characters:before {
|
||||||
|
content: 'characters: '
|
||||||
|
}
|
||||||
|
|
||||||
|
.editor-preview {
|
||||||
|
padding: 10px;
|
||||||
|
position: absolute;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
background: #fafafa;
|
||||||
|
z-index: 7;
|
||||||
|
overflow: auto;
|
||||||
|
display: none;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
|
||||||
|
.editor-preview-side {
|
||||||
|
padding: 10px;
|
||||||
|
position: fixed;
|
||||||
|
bottom: 0;
|
||||||
|
width: 50%;
|
||||||
|
top: 50px;
|
||||||
|
right: 0;
|
||||||
|
background: #fafafa;
|
||||||
|
z-index: 9;
|
||||||
|
overflow: auto;
|
||||||
|
display: none;
|
||||||
|
box-sizing: border-box;
|
||||||
|
border: 1px solid #ddd;
|
||||||
|
word-wrap: break-word;
|
||||||
|
}
|
||||||
|
|
||||||
|
.editor-preview-active-side {
|
||||||
|
display: block
|
||||||
|
}
|
||||||
|
|
||||||
|
.editor-preview-active {
|
||||||
|
display: block
|
||||||
|
}
|
||||||
|
|
||||||
|
.editor-preview>p,
|
||||||
|
.editor-preview-side>p {
|
||||||
|
margin-top: 0
|
||||||
|
}
|
||||||
|
|
||||||
|
.editor-preview pre,
|
||||||
|
.editor-preview-side pre {
|
||||||
|
background: #eee;
|
||||||
|
margin-bottom: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.editor-preview table td,
|
||||||
|
.editor-preview table th,
|
||||||
|
.editor-preview-side table td,
|
||||||
|
.editor-preview-side table th {
|
||||||
|
border: 1px solid #ddd;
|
||||||
|
padding: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cm-s-easymde .cm-tag {
|
||||||
|
color: #63a35c;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cm-s-easymde .cm-attribute {
|
||||||
|
color: #795da3;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cm-s-easymde .cm-string {
|
||||||
|
color: #183691;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cm-s-easymde .cm-header-1 {
|
||||||
|
font-size: 200%;
|
||||||
|
line-height: 200%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cm-s-easymde .cm-header-2 {
|
||||||
|
font-size: 160%;
|
||||||
|
line-height: 160%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cm-s-easymde .cm-header-3 {
|
||||||
|
font-size: 125%;
|
||||||
|
line-height: 125%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cm-s-easymde .cm-header-4 {
|
||||||
|
font-size: 110%;
|
||||||
|
line-height: 110%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cm-s-easymde .cm-comment {
|
||||||
|
background: rgba(0, 0, 0, .05);
|
||||||
|
border-radius: 2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cm-s-easymde .cm-link {
|
||||||
|
color: #7f8c8d;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cm-s-easymde .cm-url {
|
||||||
|
color: #aab2b3;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cm-s-easymde .cm-quote {
|
||||||
|
color: #7f8c8d;
|
||||||
|
font-style: italic;
|
||||||
|
}
|
8
src/index.scss
Normal file → Executable file
8
src/index.scss
Normal file → Executable file
@ -1,8 +1,5 @@
|
|||||||
@import "./vars.scss";
|
@import "./vars.scss";
|
||||||
|
|
||||||
body {
|
|
||||||
overscroll-behavior-y: contain;
|
|
||||||
}
|
|
||||||
|
|
||||||
// html {
|
// html {
|
||||||
// min-height: 100%;
|
// min-height: 100%;
|
||||||
@ -52,11 +49,6 @@ body {
|
|||||||
|
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
|
||||||
body {
|
|
||||||
overscroll-behavior-y: contain;
|
|
||||||
}
|
|
||||||
|
|
||||||
.def-shadow {
|
.def-shadow {
|
||||||
box-shadow: 0px 5px 8px 2px rgba(66, 66, 66, 0.53);
|
box-shadow: 0px 5px 8px 2px rgba(66, 66, 66, 0.53);
|
||||||
}
|
}
|
||||||
|
@ -53,41 +53,34 @@ window.cancelIdleCallback =
|
|||||||
clearTimeout(id as any);
|
clearTimeout(id as any);
|
||||||
};
|
};
|
||||||
|
|
||||||
console.log(window.requestIdleCallback);
|
// console.log(window.requestIdleCallback);
|
||||||
|
|
||||||
window.debug = {};
|
window.debug = {};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
import "@hibas123/theme/out/base.css";
|
||||||
import { h, render } from 'preact';
|
import { h, render } from 'preact';
|
||||||
import App from './components/App';
|
import App from './components/App';
|
||||||
|
|
||||||
|
|
||||||
// import "uikit";
|
|
||||||
// import "uikit/dist/css/uikit.css"
|
|
||||||
import "@hibas123/theme/out/base.css"
|
|
||||||
// import "@hibas123/theme/out/light.css"
|
|
||||||
// import "@hibas123/theme/out/dark.css"
|
|
||||||
|
|
||||||
import "./index.scss";
|
|
||||||
import Navigation from './navigation';
|
|
||||||
import VaultsPage from './components/routes/vaults/Vaults';
|
|
||||||
import { Page } from './page';
|
|
||||||
|
|
||||||
import Notes from "./notes"
|
|
||||||
import DemoPage from './components/demo';
|
import DemoPage from './components/demo';
|
||||||
import VaultPage from './components/routes/vault/Vault';
|
|
||||||
import SharePage from './components/routes/share/Share';
|
|
||||||
import Notifications from './notifications';
|
|
||||||
import Error404Page from './components/routes/404';
|
import Error404Page from './components/routes/404';
|
||||||
import SettingsPage from './components/routes/settings/Settings';
|
import SettingsPage from './components/routes/settings/Settings';
|
||||||
|
import SharePage from './components/routes/share/Share';
|
||||||
|
import VaultPage from './components/routes/vault/Vault';
|
||||||
|
import VaultsPage from './components/routes/vaults/Vaults';
|
||||||
|
import "./index.scss";
|
||||||
|
import Navigation from './navigation';
|
||||||
|
import Notes from "./notes";
|
||||||
|
import Notifications from './notifications';
|
||||||
|
import { Page } from './page';
|
||||||
|
|
||||||
|
|
||||||
window.debug.notes = Notes;
|
window.debug.notes = Notes;
|
||||||
|
|
||||||
|
|
||||||
import Theme from "./theme";
|
// import Theme from "./theme";
|
||||||
|
|
||||||
console.log("Dark mode:", Theme.active);
|
|
||||||
|
|
||||||
(async () => {
|
(async () => {
|
||||||
// Initialize notes provider
|
// Initialize notes provider
|
||||||
|
320
src/notes.ts
320
src/notes.ts
@ -9,6 +9,7 @@ import * as b64 from "./helper/base64";
|
|||||||
import IDB from "./helper/indexeddb";
|
import IDB from "./helper/indexeddb";
|
||||||
import Notifications, { MessageType } from "./notifications";
|
import Notifications, { MessageType } from "./notifications";
|
||||||
|
|
||||||
|
|
||||||
export class HttpError extends Error {
|
export class HttpError extends Error {
|
||||||
constructor(public status: number, public statusText: string) {
|
constructor(public status: number, public statusText: string) {
|
||||||
super(statusText);
|
super(statusText);
|
||||||
@ -45,7 +46,7 @@ const Decoder = new TextDecoder();
|
|||||||
enum OpLogType {
|
enum OpLogType {
|
||||||
CREATE,
|
CREATE,
|
||||||
CHANGE,
|
CHANGE,
|
||||||
DELETE,
|
DELETE
|
||||||
}
|
}
|
||||||
|
|
||||||
interface OpLog {
|
interface OpLog {
|
||||||
@ -58,8 +59,8 @@ interface OpLog {
|
|||||||
* The value
|
* The value
|
||||||
*/
|
*/
|
||||||
values: {
|
values: {
|
||||||
value: Uint8Array;
|
value: Uint8Array,
|
||||||
preview: Uint8Array;
|
preview: Uint8Array
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -68,43 +69,41 @@ interface OpLog {
|
|||||||
date: Date;
|
date: Date;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type VaultList = { name: string; encrypted: boolean; id: string }[];
|
export type VaultList = { name: string, encrypted: boolean, id: string }[];
|
||||||
|
|
||||||
export interface IVault {
|
export interface IVault {
|
||||||
name: string;
|
name: string;
|
||||||
id: string;
|
id: string;
|
||||||
encrypted: boolean;
|
encrypted: boolean;
|
||||||
getAllNotes(): Promise<BaseNote[]>;
|
getAllNotes(): Promise<BaseNote[]>;
|
||||||
searchNote(term: string): Promise<BaseNote[]>;
|
searchNote(term: string): Promise<BaseNote[]>
|
||||||
newNote(): ViewNote;
|
newNote(): ViewNote;
|
||||||
saveNote(note: ViewNote, date?: Date): Promise<void>;
|
saveNote(note: ViewNote, date?: Date): Promise<void>;
|
||||||
getNote(id: string): Promise<ViewNote>;
|
getNote(id: string): Promise<ViewNote>;
|
||||||
deleteNote(id: string): Promise<void>;
|
deleteNote(id: string): Promise<void>;
|
||||||
}
|
}
|
||||||
|
|
||||||
const awaitTimeout = (ms: number) =>
|
const awaitTimeout = (ms: number) => new Promise<void>(resolve => setTimeout(resolve, ms));
|
||||||
new Promise<void>((resolve) => setTimeout(resolve, ms));
|
|
||||||
|
|
||||||
class NotesProvider {
|
class NotesProvider {
|
||||||
private notesObservableServer = new Observable<Note>();
|
private notesObservableServer = new Observable<Note>()
|
||||||
public notesObservable = this.notesObservableServer.getPublicApi();
|
public notesObservable = this.notesObservableServer.getPublicApi()
|
||||||
|
|
||||||
private syncObservableServer = new Observable<boolean>();
|
private syncObservableServer = new Observable<boolean>()
|
||||||
/**
|
/**
|
||||||
* Will send false once finished and true on start
|
* Will send false once finished and true on start
|
||||||
*/
|
*/
|
||||||
public syncObservable = this.syncObservableServer.getPublicApi();
|
public syncObservable = this.syncObservableServer.getPublicApi()
|
||||||
|
|
||||||
private database = new IDB("notes", ["notes", "oplog"]);
|
private database = new IDB("notes", ["notes", "oplog"]);
|
||||||
private noteDB = this.database.getStore<DBNote>("notes");
|
private noteDB = this.database.getStore<DBNote>("notes");
|
||||||
private oplogDB = this.database.getStore<{ id: string; logs: OpLog[] }>(
|
private oplogDB = this.database.getStore<{ id: string, logs: OpLog[] }>("oplog");
|
||||||
"oplog"
|
|
||||||
);
|
|
||||||
|
|
||||||
private vaultKeys = new Map<string, Uint8Array>();
|
private vaultKeys = new Map<string, Uint8Array>();
|
||||||
|
|
||||||
|
|
||||||
public apiLock = new Lock();
|
public apiLock = new Lock();
|
||||||
public apiLockRls = this.apiLock.getLock();
|
public apiLockRls = this.apiLock.getLock()
|
||||||
|
|
||||||
private syncLock = new Lock();
|
private syncLock = new Lock();
|
||||||
|
|
||||||
@ -116,7 +115,7 @@ class NotesProvider {
|
|||||||
public syncedObservable = this.syncedObservableServer.getPublicApi();
|
public syncedObservable = this.syncedObservableServer.getPublicApi();
|
||||||
|
|
||||||
public async isSynced() {
|
public async isSynced() {
|
||||||
return (await this.oplogDB.getAll()).length <= 0;
|
return (await this.oplogDB.getAll()).length <= 0
|
||||||
}
|
}
|
||||||
|
|
||||||
private _name;
|
private _name;
|
||||||
@ -129,17 +128,11 @@ class NotesProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
login() {
|
login() {
|
||||||
window.location.href = `${config.auth_server}/auth?client_id=${
|
window.location.href = `${config.auth_server}/auth?client_id=${config.client_id}&scope=${config.permission}&redirect_uri=${encodeURIComponent(config.callback_url)}&response_type=code`
|
||||||
config.client_id
|
|
||||||
}&scope=${config.permission}&redirect_uri=${encodeURIComponent(
|
|
||||||
config.callback_url
|
|
||||||
)}&response_type=code`;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async getToken(code: string) {
|
async getToken(code: string) {
|
||||||
let req = await fetch(
|
let req = await fetch(`${config.auth_server}/api/oauth/refresh?grant_type=authorization_code&client_id=${config.client_id}&code=${code}`);
|
||||||
`${config.auth_server}/api/oauth/refresh?grant_type=authorization_code&client_id=${config.client_id}&code=${code}`
|
|
||||||
);
|
|
||||||
let res = await req.json();
|
let res = await req.json();
|
||||||
if (!res.error) {
|
if (!res.error) {
|
||||||
localStorage.setItem("refreshtoken", res.token);
|
localStorage.setItem("refreshtoken", res.token);
|
||||||
@ -147,9 +140,9 @@ class NotesProvider {
|
|||||||
this._name = res.profile.name;
|
this._name = res.profile.name;
|
||||||
let kb = this.passwordToKey(res.profile.enc_key);
|
let kb = this.passwordToKey(res.profile.enc_key);
|
||||||
localStorage.setItem("enc_key", b64.encode(kb));
|
localStorage.setItem("enc_key", b64.encode(kb));
|
||||||
this.generalEncryption = kb;
|
this.generalEncryption = kb
|
||||||
} else {
|
} else {
|
||||||
return "Invalid Code";
|
return "Invalid Code"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -162,11 +155,11 @@ class NotesProvider {
|
|||||||
} catch (err) {
|
} catch (err) {
|
||||||
callback(err, null);
|
callback(err, null);
|
||||||
}
|
}
|
||||||
});
|
})
|
||||||
|
|
||||||
let key = localStorage.getItem("enc_key");
|
let key = localStorage.getItem("enc_key");
|
||||||
if (key) {
|
if (key) {
|
||||||
this.generalEncryption = b64.decode(key);
|
this.generalEncryption = b64.decode(key)
|
||||||
}
|
}
|
||||||
this._name = localStorage.getItem("name");
|
this._name = localStorage.getItem("name");
|
||||||
}
|
}
|
||||||
@ -175,42 +168,34 @@ class NotesProvider {
|
|||||||
const next = () => {
|
const next = () => {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.sync().then(next);
|
this.sync().then(next);
|
||||||
}, 30000);
|
}, 30000)
|
||||||
};
|
}
|
||||||
this.syncedObservableServer.send(
|
this.syncedObservableServer.send((await this.oplogDB.getAll()).length <= 0);
|
||||||
(await this.oplogDB.getAll()).length <= 0
|
let prs = this.apiLockRls.then(lock => lock.release());
|
||||||
);
|
prs.then(() => awaitTimeout(2000)).then(() => this.sync()).then(() => next());
|
||||||
let prs = this.apiLockRls.then((lock) => lock.release());
|
|
||||||
prs.then(() => awaitTimeout(2000))
|
|
||||||
.then(() => this.sync())
|
|
||||||
.then(() => next());
|
|
||||||
return prs;
|
return prs;
|
||||||
}
|
}
|
||||||
|
|
||||||
private async getJWT() {
|
private async getJWT() {
|
||||||
let lock = await this.apiLock.getLock();
|
let lock = await this.apiLock.getLock()
|
||||||
try {
|
try {
|
||||||
console.log("Getting JWT");
|
console.log("Getting JWT");
|
||||||
let req = await fetch(
|
let req = await fetch(config.auth_server + "/api/oauth/jwt?refreshtoken=" + localStorage.getItem("refreshtoken"));
|
||||||
config.auth_server +
|
|
||||||
"/api/oauth/jwt?refreshtoken=" +
|
|
||||||
localStorage.getItem("refreshtoken")
|
|
||||||
);
|
|
||||||
if (req.status !== 200) {
|
if (req.status !== 200) {
|
||||||
Notifications.sendNotification("offline", MessageType.INFO);
|
Notifications.sendNotification("offline", MessageType.INFO);
|
||||||
throw new Error("Offline");
|
throw new Error("Offline")
|
||||||
}
|
}
|
||||||
let res = await req.json();
|
let res = await req.json();
|
||||||
if (res.error) {
|
if (res.error) {
|
||||||
console.log("Refresh token invalid, forward to login");
|
console.log("Refresh token invalid, forward to login")
|
||||||
localStorage.removeItem("refreshtoken");
|
localStorage.removeItem("refreshtoken");
|
||||||
this.login();
|
this.login()
|
||||||
throw new Error("Need login!");
|
throw new Error("Need login!")
|
||||||
} else {
|
} else {
|
||||||
return res.token;
|
return res.token
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
lock.release();
|
lock.release()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -220,38 +205,29 @@ class NotesProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async sync() {
|
async sync() {
|
||||||
const lock = await this.syncLock.getLock();
|
const lock = await this.syncLock.getLock()
|
||||||
const log = (...message: any[]) => {
|
const log = (...message: any[]) => {
|
||||||
console.log("[SYNC]: ", ...message);
|
console.log("[SYNC]: ", ...message)
|
||||||
};
|
}
|
||||||
|
|
||||||
this.syncObservableServer.send(true);
|
this.syncObservableServer.send(true);
|
||||||
log("Start");
|
log("Start")
|
||||||
try {
|
try {
|
||||||
log("Fetching");
|
log("Fetching");
|
||||||
let [remotes, locals, oplogs] = await Promise.all([
|
let [remotes, locals, oplogs] = await Promise.all([this._secureFile.list(), this.noteDB.getAll(), this.oplogDB.getAll()]);
|
||||||
this._secureFile.list(),
|
|
||||||
this.noteDB.getAll(),
|
|
||||||
this.oplogDB.getAll(),
|
|
||||||
]);
|
|
||||||
log("Fetched");
|
log("Fetched");
|
||||||
// Create sync pairs (remote & local)
|
// Create sync pairs (remote & local)
|
||||||
log("Building pairs");
|
log("Building pairs");
|
||||||
let pairs: {
|
let pairs: { local: DBNote, remote: IFile, id: string, oplog: OpLog[] }[] = [];
|
||||||
local: DBNote;
|
remotes.map(r => {
|
||||||
remote: IFile;
|
let lIdx = locals.findIndex(e => e._id === r._id);
|
||||||
id: string;
|
|
||||||
oplog: OpLog[];
|
|
||||||
}[] = [];
|
|
||||||
remotes.map((r) => {
|
|
||||||
let lIdx = locals.findIndex((e) => e._id === r._id);
|
|
||||||
let l: DBNote = undefined;
|
let l: DBNote = undefined;
|
||||||
if (lIdx >= 0) {
|
if (lIdx >= 0) {
|
||||||
l = locals[lIdx];
|
l = locals[lIdx];
|
||||||
locals.splice(lIdx, 1);
|
locals.splice(lIdx, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
let oIdx = oplogs.findIndex((e) => e.id === r._id);
|
let oIdx = oplogs.findIndex(e => e.id === r._id);
|
||||||
let oplog: OpLog[];
|
let oplog: OpLog[];
|
||||||
if (oIdx >= 0) {
|
if (oIdx >= 0) {
|
||||||
oplog = oplogs[oIdx].logs;
|
oplog = oplogs[oIdx].logs;
|
||||||
@ -262,12 +238,12 @@ class NotesProvider {
|
|||||||
remote: r,
|
remote: r,
|
||||||
local: l,
|
local: l,
|
||||||
oplog,
|
oplog,
|
||||||
id: r._id,
|
id: r._id
|
||||||
});
|
})
|
||||||
});
|
})
|
||||||
|
|
||||||
locals.forEach((l) => {
|
locals.forEach(l => {
|
||||||
let oIdx = oplogs.findIndex((e) => e.id === l._id);
|
let oIdx = oplogs.findIndex(e => e.id === l._id);
|
||||||
let oplog: OpLog[] = undefined;
|
let oplog: OpLog[] = undefined;
|
||||||
if (oIdx >= 0) {
|
if (oIdx >= 0) {
|
||||||
oplog = oplogs[oIdx].logs;
|
oplog = oplogs[oIdx].logs;
|
||||||
@ -279,20 +255,20 @@ class NotesProvider {
|
|||||||
remote: undefined,
|
remote: undefined,
|
||||||
local: l,
|
local: l,
|
||||||
oplog,
|
oplog,
|
||||||
id: l._id,
|
id: l._id
|
||||||
});
|
})
|
||||||
});
|
})
|
||||||
|
|
||||||
oplogs.forEach((oplog) => {
|
oplogs.forEach(oplog => {
|
||||||
if (!oplog) return;
|
if (!oplog) return;
|
||||||
if (oplog.logs.length > 0)
|
if (oplog.logs.length > 0)
|
||||||
pairs.push({
|
pairs.push({
|
||||||
remote: undefined,
|
remote: undefined,
|
||||||
local: undefined,
|
local: undefined,
|
||||||
oplog: oplog.logs,
|
oplog: oplog.logs,
|
||||||
id: oplog.id,
|
id: oplog.id
|
||||||
});
|
})
|
||||||
});
|
})
|
||||||
|
|
||||||
log("Pairs builded");
|
log("Pairs builded");
|
||||||
|
|
||||||
@ -303,8 +279,8 @@ class NotesProvider {
|
|||||||
local_change: 0,
|
local_change: 0,
|
||||||
local_delete: 0,
|
local_delete: 0,
|
||||||
do_nothing: 0,
|
do_nothing: 0,
|
||||||
error: 0,
|
error: 0
|
||||||
};
|
}
|
||||||
|
|
||||||
log("Start inspection");
|
log("Start inspection");
|
||||||
for (let { local, remote, oplog, id } of pairs) {
|
for (let { local, remote, oplog, id } of pairs) {
|
||||||
@ -315,19 +291,13 @@ class NotesProvider {
|
|||||||
case OpLogType.CHANGE:
|
case OpLogType.CHANGE:
|
||||||
log(id, "REMOTE CHANGE");
|
log(id, "REMOTE CHANGE");
|
||||||
stats.remote_change++;
|
stats.remote_change++;
|
||||||
await this._secureFile.update(
|
await this._secureFile.update(id, op.values.value, b64.encode(op.values.preview), op.date, old);
|
||||||
id,
|
|
||||||
op.values.value,
|
|
||||||
b64.encode(op.values.preview),
|
|
||||||
op.date,
|
|
||||||
old
|
|
||||||
);
|
|
||||||
break;
|
break;
|
||||||
case OpLogType.DELETE:
|
case OpLogType.DELETE:
|
||||||
log(id, "REMOTE DELETE");
|
log(id, "REMOTE DELETE");
|
||||||
stats.remote_delete++;
|
stats.remote_delete++;
|
||||||
if (old) break; // if the deletion is old, just ignore
|
if (old) break; // if the deletion is old, just ignore
|
||||||
await this._secureFile.delete(id);
|
await this._secureFile.delete(id)
|
||||||
break;
|
break;
|
||||||
case OpLogType.CREATE:
|
case OpLogType.CREATE:
|
||||||
log(id, "REMOTE CREATE");
|
log(id, "REMOTE CREATE");
|
||||||
@ -344,11 +314,11 @@ class NotesProvider {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
const localChange = (id: string) => {
|
const localChange = (id: string) => {
|
||||||
//TODO implement
|
//TODO implement
|
||||||
};
|
}
|
||||||
|
|
||||||
const create = async () => {
|
const create = async () => {
|
||||||
log(id, "LOCAL CREATAE/UPDATE");
|
log(id, "LOCAL CREATAE/UPDATE");
|
||||||
@ -357,43 +327,42 @@ class NotesProvider {
|
|||||||
let note: DBNote = {
|
let note: DBNote = {
|
||||||
_id: remote._id,
|
_id: remote._id,
|
||||||
folder: remote.folder,
|
folder: remote.folder,
|
||||||
preview: b64.decode(remote.active.preview || ""),
|
preview: b64.decode(remote.active.preview),
|
||||||
time: remote.active.time,
|
time: remote.active.time,
|
||||||
__value: new Uint8Array(value),
|
__value: new Uint8Array(value)
|
||||||
};
|
}
|
||||||
await this.noteDB.set(id, note);
|
await this.noteDB.set(id, note);
|
||||||
localChange(id);
|
localChange(id);
|
||||||
};
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// log(id, "LRO: ", !!local, !!remote, !!oplog)
|
// log(id, "LRO: ", !!local, !!remote, !!oplog)
|
||||||
if (remote && !oplog) {
|
if (remote && !oplog) {
|
||||||
if (local) {
|
if (local) {
|
||||||
let old =
|
let old = remote.active.time.valueOf() > local.time.valueOf();
|
||||||
remote.active.time.valueOf() > local.time.valueOf();
|
if (old)
|
||||||
if (old) await create();
|
await create()
|
||||||
else {
|
else {
|
||||||
stats.do_nothing++;
|
stats.do_nothing++;
|
||||||
log(id, "DO NOTHING");
|
log(id, "DO NOTHING");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
await create();
|
await create()
|
||||||
}
|
}
|
||||||
} else if (!remote && local && !oplog) {
|
} else if (!remote && local && !oplog) { // No local changes, but remote deleted
|
||||||
// No local changes, but remote deleted
|
|
||||||
log("LOCAL DELETE");
|
log("LOCAL DELETE");
|
||||||
stats.local_delete++;
|
stats.local_delete++;
|
||||||
await this.noteDB.delete(id);
|
await this.noteDB.delete(id);
|
||||||
localChange(id);
|
localChange(id);
|
||||||
} else if (!remote && oplog) {
|
} else if (!remote && oplog) { // Remote does not exist, but oplog, just apply all changes including possible delete
|
||||||
// Remote does not exist, but oplog, just apply all changes including possible delete
|
await apply()
|
||||||
await apply();
|
|
||||||
} else if (remote && oplog) {
|
} else if (remote && oplog) {
|
||||||
let last = oplog[oplog.length - 1];
|
let last = oplog[oplog.length - 1]
|
||||||
let old = remote.active.time.valueOf() > last.date.valueOf();
|
let old = remote.active.time.valueOf() > last.date.valueOf();
|
||||||
|
|
||||||
if (old) await create(); // Will recreate local entry
|
if (old)
|
||||||
await apply(old); // Will apply changes to remote
|
await create() // Will recreate local entry
|
||||||
|
await apply(old) // Will apply changes to remote
|
||||||
} else {
|
} else {
|
||||||
log(id, "DO NOTHING");
|
log(id, "DO NOTHING");
|
||||||
stats.do_nothing++;
|
stats.do_nothing++;
|
||||||
@ -401,20 +370,15 @@ class NotesProvider {
|
|||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
stats.error++;
|
stats.error++;
|
||||||
Notifications.sendNotification(
|
Notifications.sendNotification("Error syncing: " + id, MessageType.ERROR);
|
||||||
"Error syncing: " + id,
|
|
||||||
MessageType.ERROR
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
await this.oplogDB.delete(id);
|
await this.oplogDB.delete(id);
|
||||||
}
|
}
|
||||||
log("Stats", stats);
|
log("Stats", stats);
|
||||||
this.syncedObservableServer.send(
|
this.syncedObservableServer.send((await this.oplogDB.getAll()).length <= 0)
|
||||||
(await this.oplogDB.getAll()).length <= 0
|
|
||||||
);
|
|
||||||
} finally {
|
} finally {
|
||||||
log("Finished");
|
log("Finished")
|
||||||
lock.release();
|
lock.release()
|
||||||
this.syncObservableServer.send(false);
|
this.syncObservableServer.send(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -444,16 +408,15 @@ class NotesProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public getVaults(): Promise<VaultList> {
|
public getVaults(): Promise<VaultList> {
|
||||||
return this.noteDB.getAll().then((notes) =>
|
return this.noteDB.getAll()
|
||||||
notes
|
.then(notes => notes
|
||||||
.filter((e) => Decoder.decode(e.preview) === "__VAULT__")
|
.filter(e => Decoder.decode(e.preview) === "__VAULT__")
|
||||||
.map((e) => {
|
.map(e => {
|
||||||
let value = e.__value;
|
let value = e.__value;
|
||||||
let encrypted = false;
|
let encrypted = false;
|
||||||
if (this.decrypt(value) !== "__BASELINE__") encrypted = true;
|
if (this.decrypt(value) !== "__BASELINE__") encrypted = true;
|
||||||
return { name: e.folder, encrypted, id: e._id };
|
return { name: e.folder, encrypted, id: e._id }
|
||||||
})
|
}));
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async createVault(name: string, key?: Uint8Array) {
|
public async createVault(name: string, key?: Uint8Array) {
|
||||||
@ -462,44 +425,35 @@ class NotesProvider {
|
|||||||
_id: uuidv4(),
|
_id: uuidv4(),
|
||||||
folder: name,
|
folder: name,
|
||||||
preview: Encoder.encode("__VAULT__"),
|
preview: Encoder.encode("__VAULT__"),
|
||||||
time: new Date(),
|
time: new Date()
|
||||||
};
|
}
|
||||||
let tx = this.database.transaction();
|
let tx = this.database.transaction();
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
this.addop(
|
this.addop(vault._id, OpLogType.CREATE, {
|
||||||
vault._id,
|
value: vault.__value,
|
||||||
OpLogType.CREATE,
|
preview: vault.preview
|
||||||
{
|
}, vault.time, tx),
|
||||||
value: vault.__value,
|
this.noteDB.set(vault._id, vault)
|
||||||
preview: vault.preview,
|
|
||||||
},
|
|
||||||
vault.time,
|
|
||||||
tx
|
|
||||||
),
|
|
||||||
this.noteDB.set(vault._id, vault),
|
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async getVault(vault_id: string, key?: Uint8Array): Promise<IVault> {
|
public async getVault(vault_id: string, key?: Uint8Array): Promise<IVault> {
|
||||||
let vault = await this.noteDB.get(vault_id);
|
let vault = await this.noteDB.get(vault_id);
|
||||||
if (!vault) throw new Error("Vault not found!");
|
if (!vault) throw new Error("Vault not found!");
|
||||||
if (this.decrypt(vault.__value, key) !== "__BASELINE__")
|
if (this.decrypt(vault.__value, key) !== "__BASELINE__") throw new Error("Invalid password!");
|
||||||
throw new Error("Invalid password!");
|
return new NotesProvider.Vault(vault, key)
|
||||||
return new NotesProvider.Vault(vault, key);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async deleteVault(vault_id: string) {
|
public async deleteVault(vault_id: string) {
|
||||||
let vault = await this.noteDB.get(vault_id);
|
let vault = await this.noteDB.get(vault_id);
|
||||||
if (!vault) throw new Error("Vault not found!");
|
if (!vault) throw new Error("Vault not found!");
|
||||||
let v = new NotesProvider.Vault(vault);
|
let v = new NotesProvider.Vault(vault);
|
||||||
await Promise.all(
|
await Promise.all((await v.getAllNotes()).map(note => this.delete(note._id)));
|
||||||
(await v.getAllNotes()).map((note) => this.delete(note._id))
|
|
||||||
);
|
|
||||||
await this.delete(v.id); // This can also delete a vault
|
await this.delete(v.id); // This can also delete a vault
|
||||||
}
|
}
|
||||||
|
|
||||||
public passwordToKey(password: string) {
|
public passwordToKey(password: string) {
|
||||||
return new Uint8Array(sha256.arrayBuffer(password + config.client_id));
|
return new Uint8Array(sha256.arrayBuffer(password + config.client_id))
|
||||||
}
|
}
|
||||||
|
|
||||||
private _encrypt(value: Uint8Array, key?: Uint8Array): Uint8Array {
|
private _encrypt(value: Uint8Array, key?: Uint8Array): Uint8Array {
|
||||||
@ -510,48 +464,42 @@ class NotesProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private encrypt(value: string, key?: Uint8Array): Uint8Array {
|
private encrypt(value: string, key?: Uint8Array): Uint8Array {
|
||||||
let msg = this._encrypt(Encoder.encode(value), key);
|
let msg = this._encrypt(Encoder.encode(value), key)
|
||||||
return new Uint8Array(this._encrypt(msg, this.generalEncryption));
|
return new Uint8Array(this._encrypt(msg, this.generalEncryption))
|
||||||
}
|
}
|
||||||
|
|
||||||
private _decrypt(value: ArrayBuffer, key?: Uint8Array): Uint8Array {
|
private _decrypt(value: ArrayBuffer, key?: Uint8Array): Uint8Array {
|
||||||
if (!key) return new Uint8Array(value);
|
if (!key) return new Uint8Array(value);
|
||||||
var aesCtr = new aesjs.ModeOfOperation.ctr(key);
|
var aesCtr = new aesjs.ModeOfOperation.ctr(key);
|
||||||
var decryptedBytes = aesCtr.decrypt(value);
|
var decryptedBytes = aesCtr.decrypt(value);
|
||||||
return new Uint8Array(decryptedBytes);
|
return new Uint8Array(decryptedBytes)
|
||||||
}
|
}
|
||||||
|
|
||||||
private decrypt(value: ArrayBuffer, key?: Uint8Array): string {
|
private decrypt(value: ArrayBuffer, key?: Uint8Array): string {
|
||||||
let msg = this._decrypt(value, key);
|
let msg = this._decrypt(value, key)
|
||||||
return Decoder.decode(this._decrypt(msg, this.generalEncryption));
|
return Decoder.decode(this._decrypt(msg, this.generalEncryption))
|
||||||
}
|
}
|
||||||
|
|
||||||
async addop(
|
async addop(note_id: string, type: OpLogType, values: { value: Uint8Array, preview: Uint8Array }, date: Date, transaction?: IDBPTransaction<unknown, string[]>) {
|
||||||
note_id: string,
|
|
||||||
type: OpLogType,
|
|
||||||
values: { value: Uint8Array; preview: Uint8Array },
|
|
||||||
date: Date,
|
|
||||||
transaction?: IDBPTransaction<unknown, string[]>
|
|
||||||
) {
|
|
||||||
let tx = transaction || this.oplogDB.transaction();
|
let tx = transaction || this.oplogDB.transaction();
|
||||||
let oplog = await this.oplogDB.get(note_id, tx);
|
let oplog = await this.oplogDB.get(note_id, tx);
|
||||||
if (!oplog) oplog = { logs: [], id: note_id };
|
if (!oplog) oplog = { logs: [], id: note_id };
|
||||||
oplog.logs.push({
|
oplog.logs.push({
|
||||||
date: date,
|
date: date,
|
||||||
type,
|
type,
|
||||||
values,
|
values
|
||||||
});
|
})
|
||||||
this.syncedObservableServer.send(false);
|
this.syncedObservableServer.send(false);
|
||||||
await this.oplogDB.set(note_id, oplog, tx);
|
await this.oplogDB.set(note_id, oplog, tx);
|
||||||
}
|
}
|
||||||
|
|
||||||
async delete(id: string) {
|
async delete(id: string) {
|
||||||
let lock = await this.syncLock.getLock();
|
let lock = await this.syncLock.getLock();
|
||||||
let tx = this.database.transaction(this.oplogDB, this.noteDB);
|
let tx = this.database.transaction(this.oplogDB, this.noteDB)
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
this.addop(id, OpLogType.DELETE, null, new Date(), tx),
|
this.addop(id, OpLogType.DELETE, null, new Date(), tx),
|
||||||
this.noteDB.delete(id, tx),
|
this.noteDB.delete(id, tx)
|
||||||
]);
|
])
|
||||||
lock.release();
|
lock.release();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -574,17 +522,15 @@ class NotesProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async getAllNotes() {
|
async getAllNotes() {
|
||||||
return Notes.noteDB.getAll().then((all) =>
|
return Notes.noteDB.getAll()
|
||||||
all
|
.then(all => all.filter(e => e.folder === this.vault._id)
|
||||||
.filter((e) => e.folder === this.vault._id)
|
|
||||||
.sort(this.sort)
|
.sort(this.sort)
|
||||||
.map<BaseNote>((e) => {
|
.map<BaseNote>(e => {
|
||||||
let new_note = clonedeep(<Note>e) as BaseNote;
|
let new_note = clonedeep(<Note>e) as BaseNote
|
||||||
delete (<any>new_note).__value;
|
delete (<any>new_note).__value
|
||||||
new_note.preview = this.decrypt(e.preview);
|
new_note.preview = this.decrypt(e.preview)
|
||||||
return new_note;
|
return new_note;
|
||||||
})
|
}));
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private sort(a: DBNote, b: DBNote) {
|
private sort(a: DBNote, b: DBNote) {
|
||||||
@ -593,7 +539,7 @@ class NotesProvider {
|
|||||||
|
|
||||||
async searchNote(term: string) {
|
async searchNote(term: string) {
|
||||||
let all = await this.getAllNotes();
|
let all = await this.getAllNotes();
|
||||||
return all.filter((e) => e.preview.indexOf(term) >= 0);
|
return all.filter(e => e.preview.indexOf(term) >= 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
newNote(): ViewNote {
|
newNote(): ViewNote {
|
||||||
@ -602,8 +548,8 @@ class NotesProvider {
|
|||||||
folder: this.vault._id,
|
folder: this.vault._id,
|
||||||
time: new Date(),
|
time: new Date(),
|
||||||
__value: "",
|
__value: "",
|
||||||
preview: "",
|
preview: ""
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async saveNote(note: ViewNote, date = new Date()) {
|
async saveNote(note: ViewNote, date = new Date()) {
|
||||||
@ -612,26 +558,20 @@ class NotesProvider {
|
|||||||
let old_note = await Notes.noteDB.get(note._id, tx);
|
let old_note = await Notes.noteDB.get(note._id, tx);
|
||||||
|
|
||||||
let new_note = clonedeep(<Note>note) as DBNote;
|
let new_note = clonedeep(<Note>note) as DBNote;
|
||||||
new_note.__value = this.encrypt(note.__value);
|
new_note.__value = this.encrypt(note.__value)
|
||||||
let [title, preview] = note.__value.split("\n");
|
let [title, preview] = note.__value.split("\n");
|
||||||
if (preview) preview = "\n" + preview;
|
if (preview) preview = "\n" + preview;
|
||||||
else preview = "";
|
else preview = ""
|
||||||
new_note.preview = this.encrypt((title + preview).substr(0, 128));
|
new_note.preview = this.encrypt((title + preview).substr(0, 128))
|
||||||
new_note.time = date;
|
new_note.time = date;
|
||||||
|
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
Notes.addop(
|
Notes.addop(note._id, !old_note ? OpLogType.CREATE : OpLogType.CHANGE, {
|
||||||
note._id,
|
value: new_note.__value,
|
||||||
!old_note ? OpLogType.CREATE : OpLogType.CHANGE,
|
preview: new_note.preview
|
||||||
{
|
}, date, tx),
|
||||||
value: new_note.__value,
|
Notes.noteDB.set(note._id, new_note, tx)
|
||||||
preview: new_note.preview,
|
])
|
||||||
},
|
|
||||||
date,
|
|
||||||
tx
|
|
||||||
),
|
|
||||||
Notes.noteDB.set(note._id, new_note, tx),
|
|
||||||
]);
|
|
||||||
lock.release();
|
lock.release();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -646,10 +586,10 @@ class NotesProvider {
|
|||||||
deleteNote(id: string) {
|
deleteNote(id: string) {
|
||||||
return Notes.delete(id);
|
return Notes.delete(id);
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const Notes = new NotesProvider();
|
const Notes = new NotesProvider()
|
||||||
export default Notes;
|
export default Notes;
|
||||||
|
|
||||||
(<any>window).api = Notes;
|
(<any>window).api = Notes
|
@ -21,7 +21,6 @@ if (window.matchMedia) {
|
|||||||
mediaIsDark = ev.matches;
|
mediaIsDark = ev.matches;
|
||||||
apply();
|
apply();
|
||||||
}
|
}
|
||||||
console.log(mediaq);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -47,6 +46,7 @@ function change(state: ThemeStates) {
|
|||||||
|
|
||||||
export default {
|
export default {
|
||||||
active: () => themeConfig,
|
active: () => themeConfig,
|
||||||
change: (state: ThemeStates) => change(state)
|
change: (state: ThemeStates) => change(state),
|
||||||
|
isDark: () => isDark
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user