Compare commits
No commits in common. "db5a363bff25037af67538c17df5908a542c27b1" and "6424f667321366ac8e9600b252eacc8795c4a48f" have entirely different histories.
db5a363bff
...
6424f66732
1250
package-lock.json
generated
1250
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
31
package.json
31
package.json
@ -14,38 +14,43 @@
|
|||||||
"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/utils": "^2.1.0",
|
"@hibas123/utils": "^2.1.0",
|
||||||
"aes-js": "^3.1.2",
|
"aes-js": "^3.1.2",
|
||||||
"feather-icons": "^4.22.1",
|
"feather-icons": "^4.21.0",
|
||||||
"idb": "^4.0.3",
|
"idb": "3.0.2",
|
||||||
"js-sha256": "^0.9.0",
|
"js-sha256": "^0.9.0",
|
||||||
|
"js-sha512": "^0.8.0",
|
||||||
"lodash.clonedeep": "^4.5.0",
|
"lodash.clonedeep": "^4.5.0",
|
||||||
"secure-file-wrapper": "git+https://git.stamm.me/OpenServer/OSSecureFileWrapper.git",
|
"secure-file-wrapper": "git+https://git.stamm.me/OpenServer/OSSecureFileWrapper.git",
|
||||||
"uuid": "^3.3.2"
|
"uikit": "^3.1.5",
|
||||||
|
"uuid": "^3.3.2",
|
||||||
|
"workbox-precaching": "^4.3.1",
|
||||||
|
"workbox-routing": "^4.3.1",
|
||||||
|
"workbox-strategies": "^4.3.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@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.4",
|
||||||
|
"@types/workbox-sw": "^4.2.0",
|
||||||
"copy-webpack-plugin": "^5.0.3",
|
"copy-webpack-plugin": "^5.0.3",
|
||||||
"css-loader": "^3.0.0",
|
"css-loader": "^2.1.1",
|
||||||
"file-loader": "^4.0.0",
|
"file-loader": "^3.0.1",
|
||||||
"html-webpack-plugin": "^3.2.0",
|
"html-webpack-plugin": "^3.2.0",
|
||||||
"mini-css-extract-plugin": "^0.7.0",
|
"mini-css-extract-plugin": "^0.7.0",
|
||||||
"node-sass": "^4.12.0",
|
"node-sass": "^4.12.0",
|
||||||
"preact": "^8.3.1",
|
"preact": "^8.3.1",
|
||||||
"preact-svg-loader": "^0.2.1",
|
"preact-svg-loader": "^0.2.1",
|
||||||
"raw-loader": "^3.0.0",
|
|
||||||
"sass-loader": "^7.1.0",
|
"sass-loader": "^7.1.0",
|
||||||
"style-loader": "^0.23.1",
|
"style-loader": "^0.23.1",
|
||||||
"ts-loader": "^6.0.4",
|
"ts-loader": "^6.0.2",
|
||||||
"typescript": "^3.5.2",
|
"typescript": "^3.5.1",
|
||||||
"webpack": "^4.35.2",
|
"webpack": "^4.32.2",
|
||||||
"webpack-bundle-analyzer": "^3.3.2",
|
"webpack-bundle-analyzer": "^3.3.2",
|
||||||
"webpack-cli": "^3.3.5",
|
"webpack-cli": "^3.3.2",
|
||||||
"webpack-dev-server": "^3.7.2",
|
"webpack-dev-server": "^3.5.1",
|
||||||
"webpack-visualizer-plugin": "^0.1.11",
|
"webpack-visualizer-plugin": "^0.1.11",
|
||||||
|
"workbox-webpack-plugin": "^4.3.1",
|
||||||
"worker-loader": "^2.0.0"
|
"worker-loader": "^2.0.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,9 +27,19 @@ self.addEventListener('activate', (event) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
self.addEventListener('message', (event) => {
|
self.addEventListener('message', (event) => {
|
||||||
|
if (event.data === "clear_cache") {
|
||||||
log("Clearing cache");
|
log("Clearing cache");
|
||||||
caches.delete(CACHE);
|
caches.delete(CACHE);
|
||||||
event.waitUntil(precache());
|
}
|
||||||
|
|
||||||
|
if (event.data === "update_index") {
|
||||||
|
log("Updating index");
|
||||||
|
event.waitUntil(caches.open(CACHE).then((cache) => {
|
||||||
|
return cache.addAll(["/", "/index.html"]).then(() => {
|
||||||
|
event.ports[0].postMessage("reload");
|
||||||
|
});
|
||||||
|
}))
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
var Types;
|
var Types;
|
||||||
|
@ -3,8 +3,8 @@ import "./add_button.scss";
|
|||||||
import Plus from "feather-icons/dist/icons/plus.svg";
|
import Plus from "feather-icons/dist/icons/plus.svg";
|
||||||
export default function AddButton({ onClick }: { onClick: () => void }) {
|
export default function AddButton({ onClick }: { onClick: () => void }) {
|
||||||
return <button
|
return <button
|
||||||
title="add button"
|
title={"add button"}
|
||||||
class="fab btn-primary"
|
class="add-button-button uk-button-primary uk-border-circle def-shadow"
|
||||||
onClick={() => onClick()}
|
onClick={() => onClick()}
|
||||||
>
|
>
|
||||||
<Plus width={undefined} height={undefined} />
|
<Plus width={undefined} height={undefined} />
|
||||||
|
0
src/components/ContextMenu.tsx
Executable file
0
src/components/ContextMenu.tsx
Executable file
@ -56,7 +56,7 @@ export class Footer extends Component<{}, { synced: boolean, syncing: boolean }>
|
|||||||
text = "not synced";
|
text = "not synced";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return <footer class="elv-8">
|
return <footer class="uk-background-default def-shadow">
|
||||||
<span>
|
<span>
|
||||||
<span class={extrac} ><a onClick={() => this.onSyncClick()} ><Refresh style="height: 1em; width: 1em;"></Refresh></a></span>
|
<span class={extrac} ><a onClick={() => this.onSyncClick()} ><Refresh style="height: 1em; width: 1em;"></Refresh></a></span>
|
||||||
<span style={"margin-left: 8px; color:" + color}>{text}</span>
|
<span style={"margin-left: 8px; color:" + color}>{text}</span>
|
||||||
@ -65,7 +65,7 @@ export class Footer extends Component<{}, { synced: boolean, syncing: boolean }>
|
|||||||
Welcome <b>{Notes.name}</b>
|
Welcome <b>{Notes.name}</b>
|
||||||
</span>
|
</span>
|
||||||
<span style="color: lightgrey;">
|
<span style="color: lightgrey;">
|
||||||
v1.4
|
v1.3
|
||||||
</span>
|
</span>
|
||||||
</footer>
|
</footer>
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,7 @@ export class Router extends Component<{}, { next?: JSX.Element, current: JSX.Ele
|
|||||||
render() {
|
render() {
|
||||||
let overlay;
|
let overlay;
|
||||||
if (this.state.next) {
|
if (this.state.next) {
|
||||||
overlay = <div class="transition_container transition_slidein background-default" key={this.state.next.key} ref={(elm: HTMLDivElement) => {
|
overlay = <div class="transition_container transition_slidein uk-background-default" key={this.state.next.key} ref={(elm: HTMLDivElement) => {
|
||||||
let lst = () => {
|
let lst = () => {
|
||||||
if (this.state.next)
|
if (this.state.next)
|
||||||
this.setState({ current: this.state.next, next: undefined }, () => {
|
this.setState({ current: this.state.next, next: undefined }, () => {
|
||||||
@ -43,7 +43,7 @@ export class Router extends Component<{}, { next?: JSX.Element, current: JSX.Ele
|
|||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
return <div style="position: relative; overflow-x: hidden; width: 100vw; height: calc(100vh - 2rem);">
|
return <div style="position: relative; overflow-x: hidden; width: 100vw; height: calc(100vh - 2rem);">
|
||||||
<div class="transition_container background-default" key={this.state.current.key} ref={elm => this.mounted = elm}>
|
<div class="transition_container uk-background-default" key={this.state.current.key} ref={elm => this.mounted = elm}>
|
||||||
{this.state.current}
|
{this.state.current}
|
||||||
</div>
|
</div>
|
||||||
{overlay}
|
{overlay}
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
footer {
|
footer {
|
||||||
// z-index: 128;
|
z-index: 128;
|
||||||
position: fixed;
|
position: fixed;
|
||||||
bottom: 0;
|
bottom: 0;
|
||||||
left: 0;
|
left: 0;
|
||||||
|
@ -27,10 +27,12 @@ export class InputModal extends Modal<string> {
|
|||||||
|
|
||||||
render() {
|
render() {
|
||||||
return <Modal.BaseModal modal={this.props.modal}>
|
return <Modal.BaseModal modal={this.props.modal}>
|
||||||
<div>
|
<div class="uk-form-horizontal uk-margin-large">
|
||||||
<div class="input-group">
|
<div class="uk-margin">
|
||||||
<label for={this.rand}>{this.props.modal.fieldname}</label>
|
<label class="uk-form-label" for={this.rand}>{this.props.modal.fieldname}</label>
|
||||||
|
<div class="uk-form-controls">
|
||||||
<input
|
<input
|
||||||
|
class="uk-input"
|
||||||
id={this.rand}
|
id={this.rand}
|
||||||
type={this.props.modal.type}
|
type={this.props.modal.type}
|
||||||
placeholder={this.props.modal.fieldname}
|
placeholder={this.props.modal.fieldname}
|
||||||
@ -43,8 +45,9 @@ export class InputModal extends Modal<string> {
|
|||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-action">
|
</div>
|
||||||
<button class="btn btn-primary" onClick={() => {
|
<div class="uk-margin" style="text-align: right;">
|
||||||
|
<button class="uk-button uk-button-primary" style="display: inline-block;" onClick={() => {
|
||||||
this.props.modal.result(this.input.value);
|
this.props.modal.result(this.input.value);
|
||||||
}}>Enter</button>
|
}}>Enter</button>
|
||||||
</div>
|
</div>
|
||||||
|
@ -12,7 +12,7 @@ export default class LoadingModal extends Modal<undefined> {
|
|||||||
getComponent() {
|
getComponent() {
|
||||||
return <Modal.BaseModal modal={this}>
|
return <Modal.BaseModal modal={this}>
|
||||||
<div style="display: flex; justify-content: center;">
|
<div style="display: flex; justify-content: center;">
|
||||||
<div style="margin: 3rem;" class="">
|
<div style="margin: 3rem;" class="uk-spinner uk-icon">
|
||||||
<svg width="90" height="90" viewBox="0 0 30 30" xmlns="http://www.w3.org/2000/svg" data-svg="spinner"><circle fill="none" stroke="#000" cx="15" cy="15" r="14" style="stroke-width: 0.333333px;"></circle></svg>
|
<svg width="90" height="90" viewBox="0 0 30 30" xmlns="http://www.w3.org/2000/svg" data-svg="spinner"><circle fill="none" stroke="#000" cx="15" cy="15" r="14" style="stroke-width: 0.333333px;"></circle></svg>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -65,8 +65,8 @@ export default abstract class Modal<T> {
|
|||||||
this.props.modal.result(null)
|
this.props.modal.result(null)
|
||||||
}
|
}
|
||||||
}}>
|
}}>
|
||||||
<div id="ModalContent" class="modal" >
|
<div id="ModalContent" class="uk-card uk-card-body uk-card-body" >
|
||||||
<div class="modal-title" style="">
|
<div class="modal-title uk-card-title" style="">
|
||||||
<h3>{this.props.modal.title}</h3>
|
<h3>{this.props.modal.title}</h3>
|
||||||
{/* <div> */}
|
{/* <div> */}
|
||||||
{!this.props.modal.noClose ?
|
{!this.props.modal.noClose ?
|
||||||
|
@ -28,14 +28,16 @@ export class YesNoModal extends Modal<boolean> {
|
|||||||
|
|
||||||
render() {
|
render() {
|
||||||
return <Modal.BaseModal modal={this.props.modal}>
|
return <Modal.BaseModal modal={this.props.modal}>
|
||||||
<div class="modal-action">
|
<div class="uk-margin-large">
|
||||||
<button class="btn-primary" onClick={() => {
|
<div style="text-align: right;">
|
||||||
|
<button class="uk-button uk-button-primary uk-margin-right" style="display: inline-block;" onClick={() => {
|
||||||
this.props.modal.result(false);
|
this.props.modal.result(false);
|
||||||
}}><span style="text-decoration: underline;">N</span>o</button>
|
}}><span style="text-decoration: underline;">N</span>o</button>
|
||||||
<button class="btn-primary" onClick={() => {
|
<button class="uk-button uk-button-primary" style="display: inline-block;" onClick={() => {
|
||||||
this.props.modal.result(true);
|
this.props.modal.result(true);
|
||||||
}}><span style="text-decoration: underline;">Y</span>es</button>
|
}}><span style="text-decoration: underline;">Y</span>es</button>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
</Modal.BaseModal>
|
</Modal.BaseModal>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,25 +4,24 @@
|
|||||||
left: 0;
|
left: 0;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
|
background: rgba(0, 0, 0, 0.8);
|
||||||
z-index: 32;
|
z-index: 32;
|
||||||
animation: darkenBackground .2s linear;
|
|
||||||
background: rgba(0, 0, 0, 0.8)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@keyframes darkenBackground {
|
.modal-container>.uk-card {
|
||||||
from {
|
position: absolute;
|
||||||
background: rgba(0, 0, 0, 0);
|
left: 0;
|
||||||
}
|
right: 0;
|
||||||
|
top: 10%;
|
||||||
to {
|
width: 80%;
|
||||||
background: rgba(0, 0, 0, 0.8);
|
max-width: 800px;
|
||||||
}
|
margin: auto;
|
||||||
|
background: white;
|
||||||
}
|
}
|
||||||
|
|
||||||
.modal-title {
|
.modal-title {
|
||||||
display: flex;
|
display:flex;
|
||||||
justify-content: space-between;
|
justify-content:space-between;
|
||||||
|
|
||||||
>svg {
|
>svg {
|
||||||
height: 1em;
|
height: 1em;
|
||||||
}
|
}
|
||||||
|
@ -1,37 +0,0 @@
|
|||||||
import { h } from "preact";
|
|
||||||
import { Page } from "../../../page";
|
|
||||||
import Theme, { ThemeStates } from "../../../theme";
|
|
||||||
import Navigation from "../../../navigation";
|
|
||||||
import ArrowLeft from "feather-icons/dist/icons/arrow-left.svg";
|
|
||||||
|
|
||||||
export default class SettingsPage extends Page<{ state: any }, { vault: string }> {
|
|
||||||
componentWillMount() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
render() {
|
|
||||||
let active = Theme.active();
|
|
||||||
return <div>
|
|
||||||
<header class="header">
|
|
||||||
<a class="header-icon-button" onClick={() => history.back()}><ArrowLeft height={undefined} width={undefined} /></a>
|
|
||||||
<h3 style="display:inline" class="header-title" onClick={() => Navigation.setPage("/")}>Settings</h3>
|
|
||||||
<span></span>
|
|
||||||
</header>
|
|
||||||
<div class="container">
|
|
||||||
<div className="input-group">
|
|
||||||
<label>Select Theme: </label>
|
|
||||||
<select class="inp" onChange={(ev) => Theme.change(Number((ev.target as HTMLSelectElement).value))}>
|
|
||||||
{Object.keys(ThemeStates)
|
|
||||||
.filter(e => Number.isNaN(Number(e)))
|
|
||||||
.map(e => <option selected={ThemeStates[e] === active} value={ThemeStates[e]}>{e.charAt(0).toUpperCase() + e.slice(1).toLowerCase()}</option>)}
|
|
||||||
{/* <option value={ThemeStates.AUTO}>Auto</option>
|
|
||||||
<option value={ThemeStates.LIGHT}>Light</option>
|
|
||||||
<option value={ThemeStates.DARK}>Dark</option> */}
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
{/* <button class="btn" onClick={() => Theme.toggle()}>Toggle Dark Mode</button> */}
|
|
||||||
<button class="btn" onClick={() => window.navigator.serviceWorker.controller.postMessage("message")}>Clear cache</button>
|
|
||||||
</div>
|
|
||||||
</div >;
|
|
||||||
}
|
|
||||||
}
|
|
@ -165,17 +165,17 @@ export default class EntryComponent extends Component<{ vault: Promise<IVault>,
|
|||||||
console.log("Rerender")
|
console.log("Rerender")
|
||||||
|
|
||||||
return <div>
|
return <div>
|
||||||
<header class="header">
|
<header class="uk-background-primary">
|
||||||
<a class="header-icon-button" onClick={() => this.exitHandler()}><X height={undefined} width={undefined} /></a>
|
<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}
|
{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>
|
<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="uk-container">
|
||||||
<textarea
|
<textarea
|
||||||
value={this.text}
|
value={this.text}
|
||||||
rows={this.rows}
|
rows={this.rows}
|
||||||
class="inp"
|
class="doc uk-textarea"
|
||||||
style="width:100%;"
|
style="width:100%;"
|
||||||
onInput={this.textAreaChange}
|
onInput={this.textAreaChange}
|
||||||
onKeyDown={this.textAreaKeyPress}
|
onKeyDown={this.textAreaKeyPress}
|
||||||
|
@ -107,15 +107,15 @@ export default class EntryList extends Component<{ vault: Promise<IVault> }, { n
|
|||||||
|
|
||||||
let share;
|
let share;
|
||||||
if ((window.navigator as any).share) {
|
if ((window.navigator as any).share) {
|
||||||
share = <button class="btn" onClick={shareNote}>
|
share = <button class="uk-button" onClick={shareNote}>
|
||||||
share
|
share
|
||||||
</button>
|
</button>
|
||||||
}
|
}
|
||||||
|
|
||||||
let context = <ContextMenu event={evt} >
|
let context = <ContextMenu event={evt} >
|
||||||
{share}
|
{share}
|
||||||
<button class="btn" onClick={deleteNote}>delete</button>
|
<button class="uk-button" onClick={deleteNote}>delete</button>
|
||||||
<button class="btn" onClick={copyNote}>copy</button>
|
<button class="uk-button" onClick={copyNote}>copy</button>
|
||||||
</ContextMenu>
|
</ContextMenu>
|
||||||
|
|
||||||
this.setState({ context });
|
this.setState({ context });
|
||||||
@ -265,30 +265,32 @@ export default class EntryList extends Component<{ vault: Promise<IVault> }, { n
|
|||||||
|
|
||||||
return <div>
|
return <div>
|
||||||
{this.state.context}
|
{this.state.context}
|
||||||
<header class="header">
|
<header class="uk-background-primary">
|
||||||
<a class="header-icon-button" onClick={() => history.back()}><ArrowLeft height={undefined} width={undefined} /></a>
|
<a class="header-icon-button" onClick={() => history.back()}><ArrowLeft height={undefined} width={undefined} /></a>
|
||||||
<h3 style="display:inline" class="header-title" onClick={() => Navigation.setPage("/")}>{this.vault ? this.vault.name : ""}</h3>
|
<h3 style="display:inline" class="header-title" onClick={() => Navigation.setPage("/")}>{this.vault ? this.vault.name : ""}</h3>
|
||||||
<span></span>
|
<span></span>
|
||||||
{/* <a class="button header_icon_button"><MoreVertival height={undefined} width={undefined} /></a> */}
|
{/* <a class="button header_icon_button"><MoreVertival height={undefined} width={undefined} /></a> */}
|
||||||
</header>
|
</header>
|
||||||
<AddButton onClick={() => open_entry(null)} />
|
<AddButton onClick={() => open_entry(null)} />
|
||||||
<div class="container">
|
<div class="uk-container">
|
||||||
<div style="display:flex;">
|
<div style="display:flex;">
|
||||||
<input class="inp" type="text" style="width: 100%; height: 40px;" onKeyUp={this.searchChanged} ref={elm => this.searchInput = elm} />
|
<input class="uk-input" type="text" onKeyUp={this.searchChanged} ref={elm => this.searchInput = elm} />
|
||||||
<button class="btn btn-primary" style="padding: 5px 10px; margin: 0; height: 40px; width: 40px;">
|
<button class="uk-button uk-button-primary" style="padding: 0 10px;">
|
||||||
<Search />
|
<Search />
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="vault-list" style="margin-top: 1rem;">
|
<div class="uk-child-width-1-3@m uk-grid-small uk-grid-match" style="margin-top: 1rem;" uk-grid>
|
||||||
{this.state.notes.map(note => {
|
{this.state.notes.map(note => {
|
||||||
let [first, second] = note.preview.split("\n", 2);
|
let [first, second] = note.preview.split("\n", 2);
|
||||||
return <div class="card vault-vault" onContextMenu={evt => this.onContext(evt, note)} onClick={() => {
|
return <div class="" onContextMenu={evt => this.onContext(evt, note)} onClick={() => {
|
||||||
open_entry(note._id)
|
open_entry(note._id)
|
||||||
}}>
|
}}>
|
||||||
|
<div class="uk-card uk-card-default uk-card-body vault-vault" style="box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3)">
|
||||||
<div>{first}</div>
|
<div>{first}</div>
|
||||||
<div>{second}</div>
|
<div>{second}</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
})}
|
})}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -1,28 +1,13 @@
|
|||||||
.container> :last-child {
|
.uk-container> :last-child {
|
||||||
margin-bottom: 15px !important;
|
margin-bottom: 15px !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
.vault-list {
|
|
||||||
display: grid;
|
|
||||||
grid-template-columns: repeat(3, 1fr);
|
|
||||||
grid-gap: 1rem;
|
|
||||||
grid-auto-rows: auto;
|
|
||||||
}
|
|
||||||
|
|
||||||
@media screen and (max-width: 50rem) {
|
|
||||||
.vault-list {
|
|
||||||
grid-template-columns: 1fr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO Media Query for small screens
|
|
||||||
|
|
||||||
.vault-vault {
|
.vault-vault {
|
||||||
overflow: hidden;
|
width: 100%;
|
||||||
|
|
||||||
>div {
|
>div {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
font-size: 1.1rem;
|
font-size: 1rem;
|
||||||
margin-left: 1rem;
|
margin-left: 1rem;
|
||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
@ -41,3 +26,21 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// .vault_vault {
|
||||||
|
// padding: 0.5rem;
|
||||||
|
// border-bottom: solid 1px var(--card-border-color);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// .vault_vault:hover {
|
||||||
|
// background: var(--nav-hover-back-color);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// .vault_vault>svg {
|
||||||
|
// height: 2rem;
|
||||||
|
// margin-right: 1rem;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// .vault_vault:last-child {
|
||||||
|
// border-bottom: none;
|
||||||
|
// }
|
@ -4,7 +4,6 @@ import Notes, { VaultList } from "../../../notes";
|
|||||||
import "./vaults.scss"
|
import "./vaults.scss"
|
||||||
import Lock from "feather-icons/dist/icons/lock.svg";
|
import Lock from "feather-icons/dist/icons/lock.svg";
|
||||||
import Unlock from "feather-icons/dist/icons/unlock.svg";
|
import Unlock from "feather-icons/dist/icons/unlock.svg";
|
||||||
import Settings from "feather-icons/dist/icons/settings.svg"
|
|
||||||
import Navigation from "../../../navigation";
|
import Navigation from "../../../navigation";
|
||||||
import { InputModal } from "../../modals/InputModal";
|
import { InputModal } from "../../modals/InputModal";
|
||||||
import { YesNoModal } from "../../modals/YesNoModal";
|
import { YesNoModal } from "../../modals/YesNoModal";
|
||||||
@ -136,14 +135,14 @@ export default class VaultsPage extends Page<VaultsProps, { vaults: VaultList, m
|
|||||||
}
|
}
|
||||||
document.documentElement.addEventListener("click", close);
|
document.documentElement.addEventListener("click", close);
|
||||||
|
|
||||||
let deleteb = <button class="btn" onClick={async () => {
|
let deleteb = <button class="uk-button" onClick={async () => {
|
||||||
let delete_modal = new YesNoModal("Delete Vault? Cannot be undone!");
|
let delete_modal = new YesNoModal("Delete Vault? Cannot be undone!");
|
||||||
let result = await delete_modal.getResult();
|
let result = await delete_modal.getResult();
|
||||||
if (result) {
|
if (result) {
|
||||||
Notes.deleteVault(vault.id).then(() => {
|
Notes.deleteVault(vault.id).then(() => {
|
||||||
this.updateVaults();
|
this.updateVaults();
|
||||||
}).catch(err => {
|
}).catch(err => {
|
||||||
Notifications.sendError("Error deleting vault!")
|
Notifications.sendError("error deleting vault!")
|
||||||
console.error(err);
|
console.error(err);
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -153,15 +152,15 @@ export default class VaultsPage extends Page<VaultsProps, { vaults: VaultList, m
|
|||||||
|
|
||||||
let delete_key;
|
let delete_key;
|
||||||
if (Notes.getVaultKey(vault.id)) {
|
if (Notes.getVaultKey(vault.id)) {
|
||||||
delete_key = <button class="btn" onClick={() => {
|
delete_key = <button class="uk-button" onClick={() => {
|
||||||
Notes.forgetVaultKey(vault.id);
|
Notes.forgetVaultKey(vault.id);
|
||||||
Notifications.sendSuccess("Forgot password!")
|
Notifications.sendSuccess("Forgot key!")
|
||||||
}}>
|
}}>
|
||||||
forget password
|
forget password
|
||||||
</button>;
|
</button>;
|
||||||
}
|
}
|
||||||
|
|
||||||
let exportb = <button class="btn" onClick={async () => {
|
let exportb = <button class="uk-button" onClick={async () => {
|
||||||
let key: Uint8Array;
|
let key: Uint8Array;
|
||||||
if (vault.encrypted) {
|
if (vault.encrypted) {
|
||||||
await this.getKey(vault, false)
|
await this.getKey(vault, false)
|
||||||
@ -218,14 +217,14 @@ export default class VaultsPage extends Page<VaultsProps, { vaults: VaultList, m
|
|||||||
return <div style={{ marginTop: "-12px", paddingTop: "12px" }} >
|
return <div style={{ marginTop: "-12px", paddingTop: "12px" }} >
|
||||||
{/* {this.state.modal} */}
|
{/* {this.state.modal} */}
|
||||||
{this.state.context}
|
{this.state.context}
|
||||||
<header class="header">
|
<header class="uk-background-primary">
|
||||||
<span></span>
|
<span></span>
|
||||||
<h3 style="display:inline" onClick={() => Navigation.setPage("/")}>{this.props.selectVault ? "Select Vault for share" : "Your vaults:"}</h3>
|
<h3 style="display:inline" onClick={() => Navigation.setPage("/")}>{this.props.selectVault ? "Select Vault for share" : "Your vaults:"}</h3>
|
||||||
<a class="header-icon-button" onClick={() => Navigation.setPage("/settings")}><Settings height={undefined} width={undefined} /></a>
|
<span></span>
|
||||||
</header>
|
</header>
|
||||||
<AddButton onClick={() => this.addButtonClick()} />
|
<AddButton onClick={() => this.addButtonClick()} />
|
||||||
<div class="container">
|
<div class="uk-container">
|
||||||
<ul class="list list-divider list-clickable">
|
<ul class="uk-list uk-list-divider">
|
||||||
{elms}
|
{elms}
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
@ -1,19 +1,23 @@
|
|||||||
|
@import "../../../vars.scss";
|
||||||
|
|
||||||
.vaults_vault {
|
.vaults_vault {
|
||||||
display: flex;
|
|
||||||
padding: 0.5rem;
|
padding: 0.5rem;
|
||||||
margin-top: 0 !important;
|
margin-top: 0 !important;
|
||||||
align-items: flex-end;
|
|
||||||
justify-content: start;
|
|
||||||
|
|
||||||
>span {
|
// >span {
|
||||||
font-size: 1.5rem;
|
// font-size: 2rem !important;
|
||||||
line-height: 1.5rem;
|
// }
|
||||||
}
|
|
||||||
|
// &:not(:last-child) {
|
||||||
|
// border-bottom: 1px $border_color solid;
|
||||||
|
// }
|
||||||
|
|
||||||
>svg {
|
>svg {
|
||||||
display: inline-block;
|
height: 2rem;
|
||||||
height: 1.5em;
|
|
||||||
width: 1.5em;
|
|
||||||
margin-right: 1rem;
|
margin-right: 1rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
background: $hover-background;
|
||||||
|
}
|
||||||
}
|
}
|
@ -1,12 +1,14 @@
|
|||||||
import { Lock } from "@hibas123/utils";
|
import { Lock } from "@hibas123/utils";
|
||||||
|
|
||||||
import { openDB, IDBPDatabase, IDBPTransaction, } from "idb";
|
import { DB, openDb, Transaction } from "idb";
|
||||||
|
|
||||||
export default class IDB {
|
export default class IDB {
|
||||||
initLock = new Lock();
|
initLock = new Lock();
|
||||||
db: IDBPDatabase;
|
db: DB;
|
||||||
constructor(database: string, private stores: string[]) {
|
constructor(database: string, private stores: string[]) {
|
||||||
this.initLock.getLock().then(async l => {
|
let lock = this.initLock.getLock();
|
||||||
|
lock.then(async l => {
|
||||||
|
|
||||||
let v = localStorage.getItem(database + "_version");
|
let v = localStorage.getItem(database + "_version");
|
||||||
let version = 0;
|
let version = 0;
|
||||||
if (v) version = Number(v)
|
if (v) version = Number(v)
|
||||||
@ -19,15 +21,12 @@ export default class IDB {
|
|||||||
localStorage.setItem(database + "_version", version.toString());
|
localStorage.setItem(database + "_version", version.toString());
|
||||||
localStorage.setItem(database + "_stores", stores.join(","));
|
localStorage.setItem(database + "_stores", stores.join(","));
|
||||||
|
|
||||||
this.db = await openDB(database, version, {
|
this.db = await openDb(database, version, db => {
|
||||||
upgrade: (db) => {
|
|
||||||
console.log("IndexedDB need update")
|
console.log("IndexedDB need update")
|
||||||
const check = name => (<any>db.objectStoreNames as DOMStringList).contains ? (<any>db.objectStoreNames as DOMStringList).contains(name) : db.objectStoreNames.find(e => e === name);
|
|
||||||
stores.forEach(store => {
|
stores.forEach(store => {
|
||||||
if (!check(store))
|
if (!db.objectStoreNames.contains(store))
|
||||||
db.createObjectStore(store);
|
db.createObjectStore(store);
|
||||||
})
|
})
|
||||||
},
|
|
||||||
})
|
})
|
||||||
console.log("Got DATABASE", this.db)
|
console.log("Got DATABASE", this.db)
|
||||||
l.release();
|
l.release();
|
||||||
@ -49,42 +48,42 @@ export default class IDB {
|
|||||||
return {
|
return {
|
||||||
name: name,
|
name: name,
|
||||||
transaction: () => {
|
transaction: () => {
|
||||||
return <any>this.db.transaction(name, "readwrite") as IDBPTransaction<unknown, string[]>;
|
return this.db.transaction(name, "readwrite")
|
||||||
},
|
},
|
||||||
get: async (key: string, transaction?: IDBPTransaction<unknown, string[]>): Promise<T> => {
|
get: async (key: string, transaction?: Transaction): Promise<T> => {
|
||||||
(await this.initLock.getLock()).release()
|
(await this.initLock.getLock()).release()
|
||||||
return (transaction || this.db.transaction(name))
|
return (transaction || this.db.transaction(name))
|
||||||
.objectStore(name).get(key);
|
.objectStore(name).get(key);
|
||||||
},
|
},
|
||||||
|
|
||||||
getAll: async (transaction?: IDBPTransaction<unknown, string[]>): Promise<T[]> => {
|
getAll: async (transaction?: Transaction): Promise<T[]> => {
|
||||||
(await this.initLock.getLock()).release()
|
(await this.initLock.getLock()).release()
|
||||||
return (transaction || this.db.transaction(name))
|
return (transaction || this.db.transaction(name))
|
||||||
.objectStore(name).getAll();
|
.objectStore(name).getAll();
|
||||||
},
|
},
|
||||||
|
|
||||||
set: async (key: string, val: T, transaction?: IDBPTransaction<unknown, string[]>) => {
|
set: async (key: string, val: T, transaction?: Transaction) => {
|
||||||
(await this.initLock.getLock()).release()
|
(await this.initLock.getLock()).release()
|
||||||
const tx = (transaction || this.db.transaction(name, "readwrite"));
|
const tx = (transaction || this.db.transaction(name, "readwrite"));
|
||||||
tx.objectStore(name).put(val, key);
|
tx.objectStore(name).put(val, key);
|
||||||
return tx.done;
|
return tx.complete;
|
||||||
},
|
},
|
||||||
|
|
||||||
delete: async (key: string, transaction?: IDBPTransaction<unknown, string[]>) => {
|
delete: async (key: string, transaction?: Transaction) => {
|
||||||
(await this.initLock.getLock()).release()
|
(await this.initLock.getLock()).release()
|
||||||
const tx = (transaction || this.db.transaction(name, "readwrite"));
|
const tx = (transaction || this.db.transaction(name, "readwrite"));
|
||||||
tx.objectStore(name).delete(key);
|
tx.objectStore(name).delete(key);
|
||||||
return tx.done;
|
return tx.complete;
|
||||||
},
|
},
|
||||||
|
|
||||||
clear: async (transaction?: IDBPTransaction<unknown, string[]>) => {
|
clear: async (transaction?: Transaction) => {
|
||||||
(await this.initLock.getLock()).release()
|
(await this.initLock.getLock()).release()
|
||||||
const tx = (transaction || this.db.transaction(name, "readwrite"));
|
const tx = (transaction || this.db.transaction(name, "readwrite"));
|
||||||
tx.objectStore(name).clear();
|
tx.objectStore(name).clear();
|
||||||
return tx.done;
|
return tx.complete;
|
||||||
},
|
},
|
||||||
|
|
||||||
keys: async (transaction?: IDBPTransaction<unknown, string[]>): Promise<string[]> => {
|
keys: async (transaction?: Transaction): Promise<string[]> => {
|
||||||
(await this.initLock.getLock()).release()
|
(await this.initLock.getLock()).release()
|
||||||
const tx = (transaction || this.db.transaction(name));
|
const tx = (transaction || this.db.transaction(name));
|
||||||
const keys: string[] = [];
|
const keys: string[] = [];
|
||||||
@ -92,15 +91,13 @@ export default class IDB {
|
|||||||
|
|
||||||
// This would be store.getAllKeys(), but it isn't supported by Edge or Safari.
|
// This would be store.getAllKeys(), but it isn't supported by Edge or Safari.
|
||||||
// openKeyCursor isn't supported by Safari, so we fall back
|
// openKeyCursor isn't supported by Safari, so we fall back
|
||||||
store.getAllKeys()
|
(store.iterateKeyCursor || store.iterateCursor).call(store, (cursor: any) => {
|
||||||
|
if (!cursor) return;
|
||||||
|
keys.push(cursor.key);
|
||||||
|
cursor.continue();
|
||||||
|
});
|
||||||
|
|
||||||
// (store.iterateKeyCursor || store.iterateCursor).call(store, (cursor: any) => {
|
return tx.complete.then(() => keys);
|
||||||
// if (!cursor) return;
|
|
||||||
// keys.push(cursor.key);
|
|
||||||
// cursor.continue();
|
|
||||||
// });
|
|
||||||
|
|
||||||
return tx.done.then(() => keys);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,60 +1,65 @@
|
|||||||
@import "./vars.scss";
|
@import "./vars.scss";
|
||||||
|
|
||||||
|
* {
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
|
||||||
body {
|
body {
|
||||||
|
font-family: 'Roboto', sans-serif; // font-family: Verdana, Geneva, sans-serif;
|
||||||
|
font-size: 18px;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
overscroll-behavior-y: contain;
|
overscroll-behavior-y: contain;
|
||||||
}
|
}
|
||||||
|
|
||||||
// html {
|
html {
|
||||||
// min-height: 100%;
|
min-height: 100%;
|
||||||
// display: flex;
|
display: flex;
|
||||||
// }
|
}
|
||||||
|
|
||||||
// $header-margin: .5em;
|
$header-margin: .5em;
|
||||||
// $header-icon-size: calc(1.5rem * 1);
|
$header-icon-size: calc(1.5rem * 1);
|
||||||
// $header-icon-size: 100%;
|
// $header-icon-size: 100%;
|
||||||
|
|
||||||
// header {
|
header {
|
||||||
// display: flex;
|
display: flex;
|
||||||
// justify-content: space-between;
|
justify-content: space-between;
|
||||||
// margin-bottom: $header-margin;
|
margin-bottom: $header-margin;
|
||||||
// align-content: center;
|
align-content: center;
|
||||||
// padding: 0.75em;
|
padding: 0.75em;
|
||||||
// border-bottom: solid var(--border-color) 1px;
|
border-bottom: solid var(--border-color) 1px;
|
||||||
// background-color: var(--primary);
|
background-color: var(--primary);
|
||||||
|
|
||||||
// >* {
|
>* {
|
||||||
// margin: 0;
|
margin: 0;
|
||||||
// color: white;
|
color: white;
|
||||||
// background: var(--primary);
|
background: var(--primary);
|
||||||
// }
|
}
|
||||||
|
|
||||||
// >.header-title {
|
>.header-title {
|
||||||
// overflow: hidden;
|
overflow: hidden;
|
||||||
// text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
// text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
// white-space: nowrap;
|
white-space: nowrap;
|
||||||
// overflow: hidden;
|
overflow: hidden;
|
||||||
// flex-grow: 1;
|
flex-grow: 1;
|
||||||
// margin: 0 1em;
|
margin: 0 1em;
|
||||||
// }
|
}
|
||||||
|
|
||||||
// .header-icon-button {
|
.header-icon-button {
|
||||||
// display: block;
|
display: block;
|
||||||
// margin-top: auto;
|
margin-top: auto;
|
||||||
// margin-bottom: auto;
|
margin-bottom: auto;
|
||||||
// min-width: $header-icon-size;
|
min-width: $header-icon-size;
|
||||||
|
|
||||||
// >svg {
|
>svg {
|
||||||
// height: $header-icon-size;
|
height: $header-icon-size;
|
||||||
// width: $header-icon-size;
|
width: $header-icon-size;
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
body {
|
|
||||||
overscroll-behavior-y: contain;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.def-shadow {
|
.def-shadow {
|
||||||
|
@ -64,11 +64,8 @@ import { h, render } from 'preact';
|
|||||||
import App from './components/App';
|
import App from './components/App';
|
||||||
|
|
||||||
|
|
||||||
// import "uikit";
|
import "uikit";
|
||||||
// import "uikit/dist/css/uikit.css"
|
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 "./index.scss";
|
||||||
import Navigation from './navigation';
|
import Navigation from './navigation';
|
||||||
@ -81,14 +78,8 @@ import VaultPage from './components/routes/vault/Vault';
|
|||||||
import SharePage from './components/routes/share/Share';
|
import SharePage from './components/routes/share/Share';
|
||||||
import Notifications from './notifications';
|
import Notifications from './notifications';
|
||||||
import Error404Page from './components/routes/404';
|
import Error404Page from './components/routes/404';
|
||||||
import SettingsPage from './components/routes/settings/Settings';
|
|
||||||
window.debug.notes = Notes;
|
window.debug.notes = Notes;
|
||||||
|
|
||||||
|
|
||||||
import Theme from "./theme";
|
|
||||||
|
|
||||||
console.log("Dark mode:", Theme.active);
|
|
||||||
|
|
||||||
(async () => {
|
(async () => {
|
||||||
// Initialize notes provider
|
// Initialize notes provider
|
||||||
if (Notes.loginRequired()) {
|
if (Notes.loginRequired()) {
|
||||||
@ -99,30 +90,21 @@ console.log("Dark mode:", Theme.active);
|
|||||||
let err = await Notes.getToken(code)
|
let err = await Notes.getToken(code)
|
||||||
if (err) {
|
if (err) {
|
||||||
Notifications.sendError("Login failed: " + err)
|
Notifications.sendError("Login failed: " + err)
|
||||||
return Notes.login()
|
Notes.login()
|
||||||
} else {
|
} else {
|
||||||
window.history.replaceState(null, document.title, "/" + window.location.hash);
|
window.history.replaceState(null, document.title, "/" + window.location.hash);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return Notes.login()
|
Notes.login()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
await Notes.start();
|
await Notes.start();
|
||||||
|
|
||||||
if (window.navigator.storage && navigator.storage.persist) {
|
|
||||||
navigator.storage.persisted()
|
|
||||||
.then(has => has ? true : navigator.storage.persist())
|
|
||||||
.then(is => {
|
|
||||||
console.log("Persistant Storage:", is);
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
Navigation.default = VaultsPage as typeof Page;
|
Navigation.default = VaultsPage as typeof Page;
|
||||||
Navigation.addPage("/vault", VaultPage as typeof Page)
|
Navigation.addPage("/vault", VaultPage as typeof Page)
|
||||||
Navigation.addPage("/demo", DemoPage as typeof Page)
|
Navigation.addPage("/demo", DemoPage as typeof Page)
|
||||||
Navigation.addPage("/share", SharePage as typeof Page)
|
Navigation.addPage("/share", SharePage as typeof Page)
|
||||||
Navigation.addPage("/settings", SettingsPage as typeof Page)
|
|
||||||
Navigation.addPage("/404", Error404Page);
|
Navigation.addPage("/404", Error404Page);
|
||||||
const trad = window.location.pathname;
|
const trad = window.location.pathname;
|
||||||
if (trad && trad !== "/" && trad !== "") {
|
if (trad && trad !== "/" && trad !== "") {
|
||||||
|
22
src/notes.ts
22
src/notes.ts
@ -1,14 +1,8 @@
|
|||||||
import SecureFile, { IFile } from "@hibas123/secure-file-wrapper";
|
import * as config from "../config.json"
|
||||||
import { Lock, Observable } from "@hibas123/utils";
|
import { Lock, Observable } from "@hibas123/utils"
|
||||||
import * as aesjs from "aes-js";
|
|
||||||
import { IDBPTransaction } from "idb";
|
|
||||||
import { sha256 } from "js-sha256";
|
|
||||||
import * as uuidv4 from "uuid/v4";
|
|
||||||
import * as config from "../config.json";
|
|
||||||
import * as b64 from "./helper/base64";
|
|
||||||
import IDB from "./helper/indexeddb";
|
|
||||||
import Notifications, { MessageType } from "./notifications";
|
|
||||||
|
|
||||||
|
import SecureFile, { IFile } from "@hibas123/secure-file-wrapper";
|
||||||
|
import * as b64 from "./helper/base64"
|
||||||
|
|
||||||
export class HttpError extends Error {
|
export class HttpError extends Error {
|
||||||
constructor(public status: number, public statusText: string) {
|
constructor(public status: number, public statusText: string) {
|
||||||
@ -38,7 +32,13 @@ export interface ViewNote extends BaseNote {
|
|||||||
__value: string;
|
__value: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
import * as aesjs from "aes-js";
|
||||||
|
import { sha256 } from "js-sha256"
|
||||||
import clonedeep = require("lodash.clonedeep");
|
import clonedeep = require("lodash.clonedeep");
|
||||||
|
import * as uuidv4 from "uuid/v4"
|
||||||
|
import IDB from "./helper/indexeddb";
|
||||||
|
import { Transaction } from "idb";
|
||||||
|
import Notifications, { MessageType } from "./notifications";
|
||||||
|
|
||||||
const Encoder = new TextEncoder();
|
const Encoder = new TextEncoder();
|
||||||
const Decoder = new TextDecoder();
|
const Decoder = new TextDecoder();
|
||||||
@ -480,7 +480,7 @@ class NotesProvider {
|
|||||||
return Decoder.decode(this._decrypt(msg, this.generalEncryption))
|
return Decoder.decode(this._decrypt(msg, this.generalEncryption))
|
||||||
}
|
}
|
||||||
|
|
||||||
async addop(note_id: string, type: OpLogType, values: { value: Uint8Array, preview: Uint8Array }, date: Date, transaction?: IDBPTransaction<unknown, string[]>) {
|
async addop(note_id: string, type: OpLogType, values: { value: Uint8Array, preview: Uint8Array }, date: Date, transaction?: Transaction) {
|
||||||
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 };
|
||||||
|
52
src/theme.ts
52
src/theme.ts
@ -1,52 +0,0 @@
|
|||||||
const light = require("!!raw-loader!@hibas123/theme/out/light.css").default;
|
|
||||||
const dark = require("!!raw-loader!@hibas123/theme/out/dark.css").default;
|
|
||||||
|
|
||||||
export enum ThemeStates {
|
|
||||||
AUTO,
|
|
||||||
LIGHT,
|
|
||||||
DARK
|
|
||||||
}
|
|
||||||
|
|
||||||
let themeConfig: ThemeStates = Number(localStorage.getItem("theme"));
|
|
||||||
if (Number.isNaN(themeConfig))
|
|
||||||
themeConfig = ThemeStates.AUTO;
|
|
||||||
|
|
||||||
let isDark = false;
|
|
||||||
let mediaIsDark = false;
|
|
||||||
|
|
||||||
if (window.matchMedia) {
|
|
||||||
const mediaq = matchMedia("(prefers-color-scheme: dark)");
|
|
||||||
mediaIsDark = mediaq.matches;
|
|
||||||
mediaq.onchange = ev => {
|
|
||||||
mediaIsDark = ev.matches;
|
|
||||||
apply();
|
|
||||||
}
|
|
||||||
console.log(mediaq);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
let styleElm: HTMLStyleElement;
|
|
||||||
function apply(force?: boolean) {
|
|
||||||
let shouldDark = themeConfig === ThemeStates.AUTO ? mediaIsDark : themeConfig === ThemeStates.DARK;
|
|
||||||
if (force || shouldDark !== isDark) {
|
|
||||||
if (styleElm) styleElm.remove();
|
|
||||||
styleElm = document.createElement("style");
|
|
||||||
document.head.appendChild(styleElm);
|
|
||||||
styleElm.innerHTML = shouldDark ? dark : light;
|
|
||||||
isDark = shouldDark;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
apply(true);
|
|
||||||
|
|
||||||
|
|
||||||
function change(state: ThemeStates) {
|
|
||||||
themeConfig = state;
|
|
||||||
localStorage.setItem("theme", String(themeConfig));
|
|
||||||
apply();
|
|
||||||
}
|
|
||||||
|
|
||||||
export default {
|
|
||||||
active: () => themeConfig,
|
|
||||||
change: (state: ThemeStates) => change(state)
|
|
||||||
}
|
|
||||||
|
|
@ -1,9 +1,21 @@
|
|||||||
:root {
|
:root {
|
||||||
--primary: #1E88E5;
|
--primary: #1E88E5;
|
||||||
--on-primary: white;
|
|
||||||
// --mdc-theme-primary: var(--primary);
|
// --mdc-theme-primary: var(--primary);
|
||||||
// --mdc-theme-primary-bg: var(--mdc-theme--primary);
|
// --mdc-theme-primary-bg: var(--mdc-theme--primary);
|
||||||
// --mdc-theme-on-primary: white;
|
// --mdc-theme-on-primary: white;
|
||||||
--error: #ff2f00;
|
--error: #ff2f00;
|
||||||
--border-color: #ababab;
|
--border-color: #ababab;
|
||||||
|
--default-font-size: 1.05rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.uk-button-primary {
|
||||||
|
background: var(--primary) !important;
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uk-background-primary {
|
||||||
|
background: var(--primary) !important;
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
$hover-background: #DDDDDD;
|
@ -1,4 +1,5 @@
|
|||||||
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
|
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
|
||||||
|
const WorkboxPlugin = require("workbox-webpack-plugin");
|
||||||
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
||||||
const CopyWebpackPlugin = require('copy-webpack-plugin')
|
const CopyWebpackPlugin = require('copy-webpack-plugin')
|
||||||
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
|
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
|
||||||
|
Loading…
Reference in New Issue
Block a user