Skip to content

Commit

Permalink
Merge pull request #350 from MicroPad/next-dev
Browse files Browse the repository at this point in the history
v3.29.1
  • Loading branch information
NickGeek authored Jun 5, 2021
2 parents 77b1a7b + e08595e commit bf60fa8
Show file tree
Hide file tree
Showing 38 changed files with 786 additions and 975 deletions.
1 change: 1 addition & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ jobs:

# run tests!
- run: cd app && yarn typecheck
- run: cd app && yarn lint
- run: cd app && yarn test

build:
Expand Down
21 changes: 14 additions & 7 deletions app/package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
{
"name": "micropad",
"version": "3.29.0",
"version": "3.29.1",
"private": true,
"scripts": {
"preinstall": "python3 ../libs/build-libs.py; ./get_precache_files.py > src/extraPrecacheFiles.ts",
"start": "react-app-rewired start",
"build": "react-app-rewired build",
"test": "echo \"Tests are coming soon, hopefully.\"",
"typecheck": "yarn tsc --noEmit --p ./tsconfig.json",
"lint": "yarn eslint src/",
"eject": "react-scripts eject"
},
"dependencies": {
Expand All @@ -17,7 +18,7 @@
"date-fns": "^2.21.3",
"deep-equal": "^2.0.5",
"deep-freeze": "0.0.1",
"fend-wasm": "^0.1.14",
"fend-wasm": "^0.1.15",
"jquery": "^3.5.1",
"json-stringify-safe": "^5.0.1",
"jszip": "^3.1.5",
Expand All @@ -30,7 +31,7 @@
"pdfobject": "^2.1.1",
"querystring": "^0.2.0",
"raw-loader": "^0.5.1",
"re-resizable": "^4.4.8",
"re-resizable": "^6.9.0",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"react-draggable": "^4.3.1",
Expand All @@ -39,7 +40,7 @@
"react-redux": "^7.1.0",
"react-scripts": "^4.0.3",
"react-treeview": "^0.4.7",
"redux": "^3.7.2",
"redux": "^4.1.0",
"redux-devtools-extension": "^2.13.2",
"redux-observable": "^0.19.0",
"redux-typescript-actions": "^1.3.0",
Expand All @@ -48,7 +49,7 @@
"save-as": "^0.1.8",
"semver": "^7.3.4",
"showdown": "^1.8.6",
"typescript": "~4.2.4",
"typescript": "~4.3.2",
"upad-parse": "^7.2.0",
"vex-dialog": "^1.1.0",
"vex-js": "^4.1.0"
Expand All @@ -61,7 +62,12 @@
"**/*.ts?(x)"
],
"rules": {
"@typescript-eslint/no-use-before-define": "off"
"@typescript-eslint/no-use-before-define": "off",
"eqeqeq": ["error", "smart"],
"no-multi-spaces": "error",
"array-bracket-spacing": ["error", "never"],
"object-curly-spacing": ["error", "always"],
"key-spacing": "error"
}
}
]
Expand Down Expand Up @@ -95,6 +101,7 @@
"react-app-rewired": "^2.1.6",
"react-codemod": "^5.4.3",
"wasm-loader": "^1.3.0",
"workerize-loader": "^1.1.0"
"workerize-loader": "^1.1.0",
"eslint": "^7.27.0"
}
}
14 changes: 13 additions & 1 deletion app/src/app/actions.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import actionCreatorFactory from 'redux-typescript-actions';
import actionCreatorFactory, { ActionCreator, AsyncActionCreators } from 'redux-typescript-actions';
import { IRenameNotepadObjectAction } from './types/NotepadTypes';
import {
AddCryptoPasskeyAction,
Expand All @@ -25,6 +25,18 @@ import { HashTagSearchResults } from './reducers/SearchReducer';
import { ThemeName } from './types/Themes';
import { DueItem } from './services/DueDates';

export type MicroPadAction = ActionTypes[keyof ActionTypes];
export type ActionNames = keyof ActionFactories;

type ActionFactories = typeof actions;
type ActionTypes = {
[ActionName in ActionNames]: ActionFactories[ActionName] extends ActionCreator<any>
? ReturnType<ActionFactories[ActionName]>
: ActionFactories[ActionName] extends AsyncActionCreators<any, any, any>
? (ReturnType<ActionFactories[ActionName]['started']> | ReturnType<ActionFactories[ActionName]['done']> | ReturnType<ActionFactories[ActionName]['failed']>)
: never;
};

const actionCreator = actionCreatorFactory();

export const actions = {
Expand Down
2 changes: 1 addition & 1 deletion app/src/app/components/header/HeaderComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export default class HeaderComponent extends React.Component<IHeaderComponentPro
if (isSyncing) saveText = 'Syncing...';

return (
<header style={{position: 'fixed', zIndex: 1000}}>
<header style={{ position: 'fixed', zIndex: 1000 }}>
<Navbar className="menu-items" brand={<AppNameComponent />} href="#!" style={navStyle} right={true}>
<li style={{ marginRight: '10px', color: theme.explorerContent }}>{saveText}</li>
<ThemeDropdownComponent />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export default class NotepadBreadcrumbsComponent extends React.Component<INotepa
private readonly timeStyle: CSSProperties = {
paddingLeft: '20px',
fontFamily: 'Roboto',
fontWeight: 200 as 200
fontWeight: 200 as 200
};

render() {
Expand Down
10 changes: 5 additions & 5 deletions app/src/app/components/header/NotepadDropdownComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,13 @@ export default class NotepadDropdownComponent extends React.Component<INotepadDr
header="Export All Notepads"
trigger={<NavItem id="export-all-notepads-trigger" href="#!"><Icon left={true}>file_download</Icon> Export All</NavItem>}>
<Row>
<Col s={12} m={6} style={{cursor: 'pointer'}} onClick={exportAll}>
<Col s={12} m={6} style={{ cursor: 'pointer' }} onClick={exportAll}>
<img src={NpxIcon} style={iconStyles} title="Export notepads as a zip archive of NPX files" alt="" />
<p style={{textAlign: 'center'}}>Export notepads as a zip archive of NPX files</p>
<p style={{ textAlign: 'center' }}>Export notepads as a zip archive of NPX files</p>
</Col>
<Col s={12} m={6} style={{cursor: 'pointer'}} onClick={exportToMarkdown}>
<Col s={12} m={6} style={{ cursor: 'pointer' }} onClick={exportToMarkdown}>
<img src={MarkdownIcon} style={iconStyles} title="Export notepads as a zip archive of markdown files" alt="" />
<p style={{textAlign: 'center'}}>Export notepads as a zip archive of markdown files</p>
<p style={{ textAlign: 'center' }}>Export notepads as a zip archive of markdown files</p>
</Col>
{this.props.isExporting && <ProgressBar className="amber" />}
</Row>
Expand All @@ -76,7 +76,7 @@ export default class NotepadDropdownComponent extends React.Component<INotepadDr

<NavItem divider={true} />
{syncState.isLoading && <NavItem href="#!">Loading...</NavItem>}
{!!syncState.sharedNotepadList && Object.keys(syncState.sharedNotepadList).map(title =>
{!!syncState.sharedNotepadList && Object.keys(syncState.sharedNotepadList).map(title =>
<NavItem key={generateGuid()} href="#!" onClick={() => {
downloadNotepad!(syncState.sharedNotepadList![title].notepad);
}}>
Expand Down
2 changes: 1 addition & 1 deletion app/src/app/components/note-viewer/SourcesComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export default class SourcesComponent extends React.Component<ISourcesComponent>
bibliography.forEach(source => sources.push(
<div key={`${note.title}-source-${source.id}`}>
<a href={source.content} rel="noopener noreferrer" target="_blank">Open URL</a><br />
<Autocomplete type="url" value={source.content} label="URL" onChange={(e, v) => this.onSourceEdit(source.id, v)} data={{}} />
<Autocomplete type="url" value={source.content} label="URL" onChange={(e, v) => this.onSourceEdit(source.id, v)} data={{}} />
</div>
));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export default class FileElementComponent extends React.Component<IFileElementCo
const isEditing = elementEditing === element.args.id;

return (
<div style={{padding: '5px', width: 'max-content'}} onClick={this.openEditor}>
<div style={{ padding: '5px', width: 'max-content' }} onClick={this.openEditor}>
<em style={{ color: theme.text }}>
{!isEditing && element.args.filename}
{(isEditing || !element.args.filename) && `Upload a file...`}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { SyntheticEvent } from 'react';
import { INoteElementComponentProps } from './NoteElementComponent';
import { dataURItoBlob } from '../../../util';
import { Col, Input, Row } from 'react-materialize';
import Resizable from 're-resizable';
import { Resizable } from 're-resizable';
import { Dialog } from '../../../services/dialogs';
import { NoteElement } from 'upad-parse/dist/Note';

Expand All @@ -15,7 +15,7 @@ export default class ImageElementComponent extends React.Component<INoteElementC
const isEditing = elementEditing === element.args.id;

return (
<div style={{overflow: 'hidden', height: (isEditing) ? element.args.height! : 'auto', width: (isEditing) ? element.args.width : 'auto', minHeight: '130px'}} onClick={this.openEditor}>
<div style={{ overflow: 'hidden', height: (isEditing) ? element.args.height! : 'auto', width: (isEditing) ? element.args.width : 'auto', minHeight: '130px' }} onClick={this.openEditor}>
{
!isEditing &&
<Resizable
Expand All @@ -28,12 +28,12 @@ export default class ImageElementComponent extends React.Component<INoteElementC
this.onSizeEdit('width', ref.style.width!);
this.onSizeEdit('height', ref.style.height!);
}}>
<img style={{height: (element.args.height !== 'auto') ? '100%' : undefined, width: (element.args.width !== 'auto') ? '100%' : undefined }} src={noteAssets[element.args.ext!]} alt="" />
<img style={{ height: (element.args.height !== 'auto') ? '100%' : undefined, width: (element.args.width !== 'auto') ? '100%' : undefined }} src={noteAssets[element.args.ext!]} alt="" />
</Resizable>
}
{
isEditing &&
<div style={{height: '100%'}}>
<div style={{ height: '100%' }}>
<em style={{ color: theme.text }}>Upload a new image...</em><br />
<input type="file" onChange={this.fileSelected} style={{ padding: '5px', color: theme.text }} />

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ export default class NoteElementComponent extends React.Component<INoteElementCo
const backgroundColour = theme.background === '#000' ? ThemeValues.Midnight.background : theme.background;
const elementStyles = {
width: (element.type !== 'image' && element.type !== 'markdown') ? element.args.width : 'auto',
backgroundColor: (isEditing) ? backgroundColour : undefined
backgroundColor: (isEditing) ? backgroundColour : undefined,
overflow: 'hidden'
};

let elementComponent: JSX.Element | undefined = undefined;
Expand Down Expand Up @@ -165,11 +166,11 @@ export default class NoteElementComponent extends React.Component<INoteElementCo
<EditDueDateComponent element={element} theme={theme} updateElement={updateElement!} />

<Row style={{ paddingLeft: '5px', paddingTop: '10px' }}>
<Button className="red" waves="light" onClick={this.delete} style={{marginRight: '5px'}}><Icon left={true}>delete_forever</Icon> Delete</Button>
<Button className="red" waves="light" onClick={this.delete} style={{ marginRight: '5px' }}><Icon left={true}>delete_forever</Icon> Delete</Button>
</Row>

<Row style={{ paddingLeft: '5px' }}>
<Button className="btn-flat" waves="light" onClick={() => edit('')} style={{marginRight: '5px', float: 'right'}}>Close editor (autosaved)</Button>
<Button className="btn-flat" waves="light" onClick={() => edit('')} style={{ marginRight: '5px', float: 'right' }}>Close editor (autosaved)</Button>
</Row>
</div>
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import * as React from 'react';
import { SyntheticEvent } from 'react';
import { INoteElementComponentProps } from './NoteElementComponent';
import { Row, Col, Input } from 'react-materialize';
import Resizable from 're-resizable';
import { Col, Input, Row } from 'react-materialize';
import { Resizable } from 're-resizable';
import { dataURItoBlob } from '../../../util';
import { Dialog } from '../../../services/dialogs';
import * as PDFObject from 'pdfobject';
Expand All @@ -20,7 +20,7 @@ export default class PdfElementComponent extends React.Component<INoteElementCom
this.isEditing = elementEditing === element.args.id;

// The PDF.js viewer must have a fixed height so disallow auto and set to the minimum (500px)
const elementHeight = element.args.height === 'auto' ? '500px' : element.args.height;
const elementHeight = element.args.height === 'auto' ? '500px' : (element.args.height ?? '500px');

return (
<div style={{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ export default class RecordingElementComponent extends React.Component<IFileElem
const { element, noteAssets, downloadAsset, elementEditing } = this.props;
const isEditing = elementEditing === element.args.id;

if (isEditing && !this.canRecord) return <div style={{padding: '5px', width: '400px'}}><p>Recording is not supported</p></div>;
if (isEditing && !this.canRecord) return <div style={{ padding: '5px', width: '400px' }}><p>Recording is not supported</p></div>;

return (
<div style={{padding: '5px', width: (!isEditing) ? 'max-content' : '400px'}}>
<div style={{ padding: '5px', width: (!isEditing) ? 'max-content' : '400px' }}>
{
isEditing &&
<div ref={e => this.buttonContainer = e!} className="recording-inactive">
Expand All @@ -57,7 +57,7 @@ export default class RecordingElementComponent extends React.Component<IFileElem
}

componentDidMount() {
const { updateElement, element, edit} = this.props;
const { updateElement, element, edit } = this.props;

this.recorder.onstart = () => {
this.buttonContainer.classList.remove('recording-inactive');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { INoteElementComponentProps } from '../NoteElementComponent';
import * as React from 'react';
import { dataURItoBlob } from '../../../../util';
import { trim } from './trim-canvas';
import Resizable from 're-resizable';
import { Resizable } from 're-resizable';
import { Input, Row } from 'react-materialize';
import stringify from 'json-stringify-safe';
import * as FullScreenService from '../../../../services/FullscreenService';
Expand Down Expand Up @@ -52,7 +52,7 @@ export default class DrawingElementComponent extends React.Component<IDrawingEle
return (
<div>
<Resizable
style={{padding: '5px', overflow: 'hidden'}}
style={{ padding: '5px', overflow: 'hidden' }}
minWidth={410}
minHeight={130}
lockAspectRatio={true}
Expand Down Expand Up @@ -82,10 +82,10 @@ export default class DrawingElementComponent extends React.Component<IDrawingEle
ref={e => this.canvasElement = e!}
width="500"
height="450"
style={{border: 'solid black 1px', touchAction: 'none'}} />
style={{ border: 'solid black 1px', touchAction: 'none' }} />
</Resizable>

<Row style={{padding: '5px'}}>
<Row style={{ padding: '5px' }}>
<Input label="Erase Mode" type="checkbox" className="filled-in" onChange={(e, v) => this.isErasing = v} />
<Input label={<a target="_blank" rel="noopener noreferrer nofollow" href="https://pride.codes">Rainbow Mode</a>} type="checkbox" className="filled-in" onChange={(e, v) => this.isRainbow = v} />
</Row>
Expand All @@ -103,7 +103,7 @@ export default class DrawingElementComponent extends React.Component<IDrawingEle
minHeight: '130px',
backgroundColor: !isEditing ? theme.drawingBackground : undefined
}} onClick={this.openEditor}>
<img ref={elm => this.imageElement = elm!} style={{height: 'auto', width: 'auto', minWidth: '0px', minHeight: '0px'}} src={noteAssets[element.args.ext!]} alt="" />
<img ref={elm => this.imageElement = elm!} style={{ height: 'auto', width: 'auto', minWidth: '0px', minHeight: '0px' }} src={noteAssets[element.args.ext!]} alt="" />
</div>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { debounce } from '../../../../util';
import Grid from '@material-ui/core/Grid';
import { Input } from 'react-materialize';
import MarkdownHelpComponent from './MarkdownHelpComponent';
import Resizable from 're-resizable';
import { Resizable } from 're-resizable';
import { NoteElement } from 'upad-parse/dist/Note';
import { ITheme } from '../../../../types/Themes';
import { colourTransformer, fendTransformer } from './MarkdownTransformers';
Expand Down Expand Up @@ -80,7 +80,7 @@ export default class MarkdownElementComponent extends React.Component<IMarkdownE

return (
<Resizable
style={{overflow: 'hidden'}}
style={{ overflow: 'hidden' }}
size={{ width, height }}
minWidth={minWidth}
enable={{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export const fendTransformer: MarkdownTransformer = {
// e.g. [[1+1]] -> 2
text.replace(/\[\[([^]+?)\]\]/gi, (match, content) => {
let result = evaluateFendWithTimeout(content, 500);
if (result === "Error: Interrupted") {
if (result === "Error: interrupted") {
result = "Error: Calculation timed out";
}
if (result.startsWith("Error:")) {
Expand Down
Loading

0 comments on commit bf60fa8

Please sign in to comment.