Optimizing a bit of stuff
This commit is contained in:
parent
609ca4d3f5
commit
b54fbe2059
3313
public/encoding.js
Normal file
3313
public/encoding.js
Normal file
File diff suppressed because it is too large
Load Diff
@ -64,6 +64,9 @@ export class Footer extends Component<{}, { synced: boolean, syncing: boolean }>
|
|||||||
<span>
|
<span>
|
||||||
Welcome <b>{Notes.name}</b>
|
Welcome <b>{Notes.name}</b>
|
||||||
</span>
|
</span>
|
||||||
|
<span style="color: lightgrey;">
|
||||||
|
v1.0
|
||||||
|
</span>
|
||||||
</footer>
|
</footer>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ export class Router extends Component<{}, { next?: JSX.Element, current: JSX.Ele
|
|||||||
{this.state.next}
|
{this.state.next}
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
return <div style="position: relative; overflow-x: hidden; width: 100vw; height: 100vh;">
|
return <div style="position: relative; overflow-x: hidden; width: 100vw; height: calc(100vh - 2rem);">
|
||||||
<div class="transition_container uk-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>
|
||||||
|
@ -1,14 +1,12 @@
|
|||||||
import { h, Component } from "preact"
|
import { h, Component } from "preact"
|
||||||
import Notes, { IVault, ViewNote } from "../../../notes";
|
import { IVault, ViewNote } from "../../../notes";
|
||||||
import Trash from "feather-icons/dist/icons/trash-2.svg"
|
import Trash from "feather-icons/dist/icons/trash-2.svg"
|
||||||
import X from "feather-icons/dist/icons/x.svg"
|
import X from "feather-icons/dist/icons/x.svg"
|
||||||
import Save from "feather-icons/dist/icons/save.svg"
|
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 LoadingModal from "../../modals/LoadingModal";
|
|
||||||
import Notifications, { MessageType } from "../../../notifications";
|
import Notifications, { MessageType } from "../../../notifications";
|
||||||
import Modal from "../../modals/Modal";
|
|
||||||
|
|
||||||
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 }> {
|
||||||
@ -21,15 +19,23 @@ export default class EntryComponent extends Component<{ vault: Promise<IVault>,
|
|||||||
|
|
||||||
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() {
|
||||||
|
this.inputElm.focus();
|
||||||
|
}
|
||||||
|
|
||||||
async componentWillMount() {
|
async componentWillMount() {
|
||||||
this.text = "";
|
this.text = "";
|
||||||
this.vault = undefined;
|
this.vault = undefined;
|
||||||
@ -39,8 +45,6 @@ export default class EntryComponent extends Component<{ vault: Promise<IVault>,
|
|||||||
this.setState({ changed: false, title: "" });
|
this.setState({ changed: false, title: "" });
|
||||||
try {
|
try {
|
||||||
this.skip_save = false;
|
this.skip_save = false;
|
||||||
// this.loading = new LoadingModal();
|
|
||||||
// this.loading.show();
|
|
||||||
|
|
||||||
this.vault = await this.props.vault;
|
this.vault = await this.props.vault;
|
||||||
let note: ViewNote;
|
let note: ViewNote;
|
||||||
@ -57,7 +61,6 @@ export default class EntryComponent extends Component<{ vault: Promise<IVault>,
|
|||||||
|
|
||||||
if (!note) {
|
if (!note) {
|
||||||
Notifications.sendNotification("Note not found!", MessageType.ERROR);
|
Notifications.sendNotification("Note not found!", MessageType.ERROR);
|
||||||
// this.toVault()
|
|
||||||
} else {
|
} else {
|
||||||
this.note = note;
|
this.note = note;
|
||||||
this.text = note.__value;
|
this.text = note.__value;
|
||||||
@ -65,14 +68,8 @@ export default class EntryComponent extends Component<{ vault: Promise<IVault>,
|
|||||||
if (rows !== this.rows) {
|
if (rows !== this.rows) {
|
||||||
this.rows = rows;
|
this.rows = rows;
|
||||||
}
|
}
|
||||||
// async onKeypress(event) {
|
|
||||||
// event = event || window.event;
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
let [title] = this.text.split("\n", 1);
|
let [title] = this.text.split("\n", 1);
|
||||||
this.setState({ title, changed })
|
this.setState({ title, changed })
|
||||||
// if (this.loading)
|
|
||||||
// this.loading.close();
|
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
Notifications.sendError(err);
|
Notifications.sendError(err);
|
||||||
@ -108,11 +105,12 @@ export default class EntryComponent extends Component<{ vault: Promise<IVault>,
|
|||||||
|
|
||||||
textAreaChange(evt: KeyboardEvent) {
|
textAreaChange(evt: KeyboardEvent) {
|
||||||
if (evt.keyCode === 17 || evt.keyCode === 27) return; //No character, so not relevant for this function
|
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 target = (evt.target as HTMLTextAreaElement)
|
||||||
let value = target.value;
|
let value = target.value;
|
||||||
|
|
||||||
this.text = value;
|
this.text = value;
|
||||||
if (!this.state.changed && this.textAreaKeyPress(evt)) this.setState({ changed: true })
|
|
||||||
|
|
||||||
let [title] = value.split("\n", 1);
|
let [title] = value.split("\n", 1);
|
||||||
if (title !== this.state.title)
|
if (title !== this.state.title)
|
||||||
@ -138,6 +136,7 @@ export default class EntryComponent extends Component<{ vault: Promise<IVault>,
|
|||||||
}
|
}
|
||||||
|
|
||||||
textAreaKeyPress(evt: KeyboardEvent) {
|
textAreaKeyPress(evt: KeyboardEvent) {
|
||||||
|
console.log(evt);
|
||||||
if ((evt.keyCode === 83 || evt.keyCode === 13) && evt.ctrlKey) {
|
if ((evt.keyCode === 83 || evt.keyCode === 13) && evt.ctrlKey) {
|
||||||
evt.preventDefault()
|
evt.preventDefault()
|
||||||
this.save();
|
this.save();
|
||||||
@ -161,39 +160,27 @@ export default class EntryComponent extends Component<{ vault: Promise<IVault>,
|
|||||||
const delete_handler = async () => {
|
const delete_handler = async () => {
|
||||||
await this.vault.deleteNote(this.props.id);
|
await this.vault.deleteNote(this.props.id);
|
||||||
this.toVault()
|
this.toVault()
|
||||||
// async onKeypress(event) {
|
|
||||||
// event = event || window.event;
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log("Rerender")
|
||||||
|
|
||||||
return <div>
|
return <div>
|
||||||
<header class="uk-background-primary">
|
<header class="uk-background-primary">
|
||||||
{/* <div> */}
|
|
||||||
<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}
|
||||||
{/* </div> */}
|
|
||||||
<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="uk-container">
|
<div class="uk-container">
|
||||||
<textarea
|
<textarea
|
||||||
// async onKeypress(event) {
|
|
||||||
// event = event || window.event;
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
autofocus
|
|
||||||
value={this.text}
|
value={this.text}
|
||||||
rows={this.rows}
|
rows={this.rows}
|
||||||
class="doc uk-textarea"
|
class="doc uk-textarea"
|
||||||
style="width:100%;"
|
style="width:100%;"
|
||||||
onInput={evt => this.textAreaChange(evt as KeyboardEvent)}
|
onInput={this.textAreaChange}
|
||||||
onKeyDown={evt => this.textAreaKeyPress(evt)}
|
onKeyDown={this.textAreaKeyPress}
|
||||||
onChange={evt => this.textAreaChange(evt as KeyboardEvent)}
|
onChange={this.textAreaChange}
|
||||||
ref={elm => {
|
ref={elm => this.inputElm = elm}
|
||||||
if (elm)
|
|
||||||
setTimeout(() => elm.focus(), 500)
|
|
||||||
}}
|
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -72,7 +72,6 @@ export default class EntryList extends Component<{ vault: Promise<IVault> }, { n
|
|||||||
} else {
|
} else {
|
||||||
Notifications.sendError("Sharing not possible on this device")
|
Notifications.sendError("Sharing not possible on this device")
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let share;
|
let share;
|
||||||
|
@ -1,7 +1,10 @@
|
|||||||
|
.uk-container> :last-child {
|
||||||
|
margin-bottom: 15px !important;
|
||||||
|
}
|
||||||
|
|
||||||
.vault-vault {
|
.vault-vault {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
|
||||||
>div {
|
>div {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
font-size: 1rem;
|
font-size: 1rem;
|
||||||
@ -17,7 +20,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
>div:empty {
|
>div:empty {
|
||||||
&::before{
|
&::before {
|
||||||
content: " ";
|
content: " ";
|
||||||
white-space: pre;
|
white-space: pre;
|
||||||
}
|
}
|
||||||
|
@ -218,7 +218,7 @@ export default class VaultsPage extends Page<VaultsProps, { vaults: VaultList, m
|
|||||||
{this.state.context}
|
{this.state.context}
|
||||||
<header class="uk-background-primary">
|
<header class="uk-background-primary">
|
||||||
<span></span>
|
<span></span>
|
||||||
<h3 style="display:inline" class="header_title" onClick={() => Navigation.setPage("/")}>Your vaults:</h3>
|
<h3 style="display:inline" onClick={() => Navigation.setPage("/")}>Your vaults:</h3>
|
||||||
<span></span>
|
<span></span>
|
||||||
</header>
|
</header>
|
||||||
<AddButton onClick={() => this.addButtonClick()} />
|
<AddButton onClick={() => this.addButtonClick()} />
|
||||||
|
@ -5,7 +5,6 @@
|
|||||||
height: 100%;
|
height: 100%;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
overflow: auto;
|
overflow: auto;
|
||||||
padding-bottom: 40px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.transition_slidein {
|
.transition_slidein {
|
||||||
@ -21,6 +20,7 @@
|
|||||||
from {
|
from {
|
||||||
left: 100%;
|
left: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
to {
|
to {
|
||||||
left: 0%;
|
left: 0%;
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png">
|
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png">
|
||||||
<link rel="mask-icon" href="/safari-pinned-tab.svg" color="#3E9AE9">
|
<link rel="mask-icon" href="/safari-pinned-tab.svg" color="#3E9AE9">
|
||||||
|
<script src="encoding.js"></script>
|
||||||
<meta name="msapplication-TileColor" content="#3E9AE9">
|
<meta name="msapplication-TileColor" content="#3E9AE9">
|
||||||
<meta name="theme-color" content="#3E9AE9">
|
<meta name="theme-color" content="#3E9AE9">
|
||||||
</head>
|
</head>
|
||||||
|
@ -33,6 +33,8 @@ header {
|
|||||||
|
|
||||||
>* {
|
>* {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
|
color: white;
|
||||||
|
background: var(--primary);
|
||||||
}
|
}
|
||||||
|
|
||||||
>.header-title {
|
>.header-title {
|
||||||
@ -49,7 +51,6 @@ header {
|
|||||||
display: block;
|
display: block;
|
||||||
margin-top: auto;
|
margin-top: auto;
|
||||||
margin-bottom: auto;
|
margin-bottom: auto;
|
||||||
color: black;
|
|
||||||
min-width: $header-icon-size;
|
min-width: $header-icon-size;
|
||||||
|
|
||||||
>svg {
|
>svg {
|
||||||
|
@ -524,6 +524,7 @@ class NotesProvider {
|
|||||||
async getAllNotes() {
|
async getAllNotes() {
|
||||||
return Notes.noteDB.getAll()
|
return Notes.noteDB.getAll()
|
||||||
.then(all => all.filter(e => e.folder === this.vault._id)
|
.then(all => all.filter(e => e.folder === this.vault._id)
|
||||||
|
.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
|
||||||
@ -532,6 +533,10 @@ class NotesProvider {
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private sort(a: DBNote, b: DBNote) {
|
||||||
|
return new Date(b.time).getTime() - new Date(a.time).getTime();
|
||||||
|
}
|
||||||
|
|
||||||
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)
|
||||||
|
Loading…
Reference in New Issue
Block a user