Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adjust font size #50

Merged
merged 5 commits into from
Aug 21, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions .babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"node": 8,
"modules": false
}
}]
}],
"flow"
],
"env": {
"main": {
Expand All @@ -15,7 +16,8 @@
"node": 8,
"modules": false
}
}]
}],
"flow"
]
},
"renderer": {
Expand All @@ -29,7 +31,8 @@
}],
"react",
"react-optimize",
"stage-0"
"stage-0",
"flow"
],
"plugins": [
"transform-decorators-legacy",
Expand All @@ -38,7 +41,7 @@
]
},
"test": {
"presets": [["env"], "react"]
"presets": [["env"], "react", "flow"]
}
},
"plugins": ["transform-runtime"]
Expand Down
1 change: 1 addition & 0 deletions .eslintrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ plugins:
- jsx-a11y
- import
- jest
- flowtype
rules:
no-console:
- error
Expand Down
12 changes: 12 additions & 0 deletions .flowconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[ignore]
.*/node_modules/.*

[include]

[libs]

[lints]

[options]

[strict]
4 changes: 4 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"flow.useNPMPackagedFlow": true,
"javascript.validate.enable": false
}
2 changes: 2 additions & 0 deletions app/views/actions/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,5 @@ export const CLOSE_UPDATE_NOTIFICATION = 'CLOSE_UPDATE_NOTIFICATION';
export const CHANGE_IMAGE_HOSTING = 'CHANGE_IMAGE_HOSTING';

export const CHANGE_MEDIUM_CONFIG = 'CHANGE_MEDIUM_CONFIG';

export const CHANGE_FONT_SIZE = 'CHANGE_FONT_SIZE';
1 change: 0 additions & 1 deletion app/views/assets/scss/note.scss
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,6 @@
font-family: monospace, "BlinkMacSystemFont", "Helvetica Neue", Helvetica, "Microsoft YaHei", "微软雅黑", "Arial", "Lucida Grande", "Segoe UI", Ubuntu, Cantarell, sans-serif;
background-color: #fcfdfe;
height: 100%;
font-size: 1.1rem;

.CodeMirror-gutters {
background-color: #fcfdfe;
Expand Down
72 changes: 70 additions & 2 deletions app/views/assets/scss/settings.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,65 @@
flex: 1 1 auto;
@include display-flex;
flex-direction: column;
position: relative;

.settings-toc {
position: absolute;
left: 5%;
top: 6rem;

.ant-anchor-wrapper {
background-color: transparent;
padding-left: 0;
margin-left: 0;
padding-right: 4px;
margin-right: -4px;
}

.ant-anchor-link {
padding: 8px 16px;
line-height: 1.2;
}

.ant-anchor-ink {
right: 0;
left: unset;
}

.ant-anchor-link-title {
&:focus {
text-decoration: none;
}
}
}


.modules {
flex: 1 1 auto;
height: 0;
overflow-y: auto;

.setting-tabs {
height: 100%;
width: 90%;
margin: 0 auto;
padding: 3rem 0;
}

.settings-module {
width: 80%;
margin: 1rem auto 2rem auto;
width: 75%;
margin: 0 5% 0 20%;
padding: 2rem 3rem;

&:first-child {
padding-top: 3rem;
}

.module-title {
position: relative;
border-bottom: 2px solid $lightHeaderBorder;
padding-bottom: 0.5rem;
margin-bottom: 1.2rem;
height: 2em;
span {
position: absolute;
Expand All @@ -27,5 +73,27 @@
}
}
}

.anticon-question-circle-o {
font-size: 18px;
}
}

.font-size-row {
color: rgba(0, 0, 0, 0.85);
height: 3rem;
line-height: 3rem;
margin-top: 0.6rem;

.row-label {
padding-right: 0.5em;
text-align: right;
}
.number-col {
padding-left: 1em;
}
.ant-slider-rail {
background-color: #e5e5e5;
}
}
}
2 changes: 1 addition & 1 deletion app/views/component/cloud/Drive.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { Component, Fragment } from 'react';
import PropTypes from 'prop-types';
import { Breadcrumb, message, Icon, Modal } from 'antd';
import autobind from 'autobind-decorator';
import { withDispatch } from 'Components/HOC/withDispatch';
import { withDispatch } from 'Components/HOC/context';
import Notebooks from './Notebooks';
import Notes from './Notes';
import Loading from '../share/Loading';
Expand Down
7 changes: 4 additions & 3 deletions app/views/component/editor/Editor.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import 'codemirror/addon/fold/markdown-fold';
import 'codemirror/mode/markdown/markdown';
import ReactResizeDetector from 'react-resize-detector';
import { UPLOAD_IMAGE } from 'Actions/imageHosting';
import { withDispatch } from 'Components/HOC/withDispatch';
import { withDispatch } from 'Components/HOC/context';
import Notification from '../share/Notification';
import { updateMarkdownHtml } from '../../actions/markdown';
import { throttle, debounce } from '../../utils/utils';
Expand Down Expand Up @@ -45,6 +45,7 @@ export default class Editor extends Component {
editorWidth: PropTypes.string.isRequired,
setDrag: PropTypes.func.isRequired,
editorMode: PropTypes.string.isRequired,
fontSize: PropTypes.number.isRequired,
editorWidthValue: PropTypes.number.isRequired,
drag: PropTypes.bool.isRequired,
setPreiewScrollRatio: PropTypes.func.isRequired,
Expand Down Expand Up @@ -317,7 +318,7 @@ export default class Editor extends Component {

render() {
// const { textWidth } = this.state;
const { editorWidth, editorMode, editorWidthValue, drag } = this.props;
const { editorWidth, editorMode, editorWidthValue, drag, fontSize } = this.props;
let width = editorWidth;
let rootClass = '';
let split = true;
Expand All @@ -337,7 +338,7 @@ export default class Editor extends Component {
return (
<div
className={`editor-root ${rootClass} ${noBorder} ${drag ? 'drag' : ''}`}
style={{ flexBasis: width }}
style={{ flexBasis: width, fontSize: `${fontSize}px` }}
ref={node => (this.editorRoot = node)}
>
<ReactResizeDetector handleWidth onResize={this.handleCodeMirrorResize} />
Expand Down
8 changes: 7 additions & 1 deletion app/views/component/editor/Markdown.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ export default class Markdown extends Component {
domain: PropTypes.string.isRequired,
}).isRequired,
}).isRequired,
editor: PropTypes.shape({
fontSize: PropTypes.number.isRequired,
previewFontSize: PropTypes.number.isRequired,
}).isRequired,
editorMode: PropTypes.string.isRequired,
};

Expand Down Expand Up @@ -136,7 +140,7 @@ export default class Markdown extends Component {
}

render() {
const { markdown: { content, status, html, start, uuid }, editorMode, note, imageHostingConfig } = this.props;
const { markdown: { content, status, html, start, uuid }, editorMode, note, imageHostingConfig, editor: { fontSize, previewFontSize } } = this.props;
const { editorWidth, drag, editorWidthValue } = this.state;
if (status === 0) {
return null;
Expand All @@ -152,6 +156,7 @@ export default class Markdown extends Component {
ref={node => (this.root = node)}
>
<Editor
fontSize={fontSize}
uuid={uuid}
note={note}
imageHostingConfig={imageHostingConfig}
Expand All @@ -170,6 +175,7 @@ export default class Markdown extends Component {
editorMode={editorMode}
editorWidth={editorWidth}
editorWidthValue={editorWidthValue}
fontSize={previewFontSize}
ref={node => (this.preview = node)}
/>
</div>
Expand Down
12 changes: 11 additions & 1 deletion app/views/component/editor/Preview.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,15 @@ export default class Preview extends PureComponent {
html: PropTypes.string.isRequired,
editorMode: PropTypes.string.isRequired,
// editorWidth: PropTypes.string.isRequired,
fontSize: PropTypes.number.isRequired,
drag: PropTypes.bool.isRequired,
editorWidthValue: PropTypes.number.isRequired,
};

static defalutProps = {
fontSize: 16,
};

constructor(props) {
super(props);
const bodyWidth = this.getBodyWidth(props);
Expand All @@ -46,6 +51,10 @@ export default class Preview extends PureComponent {
bodyWidth,
});
}
if (this.props.fontSize !== nextProps.fontSize) {
const { fontSize } = nextProps.fontSize;
this.webview.send('wv-change-fontsize', fontSize);
}
}

componentDidUpdate() {
Expand Down Expand Up @@ -74,12 +83,13 @@ export default class Preview extends PureComponent {
@autobind
onWVMessage(event) {
const channel = event.channel;
const { html, editorMode } = this.props;
const { html, editorMode, fontSize } = this.props;
switch (channel) {
case 'wv-first-loaded': {
this.webview.send('wv-render-html', {
html,
editorMode,
fontSize,
});
this.setState({
loading: false,
Expand Down
2 changes: 1 addition & 1 deletion app/views/component/note/Explorer.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { Component, Fragment } from 'react';
import PropTypes from 'prop-types';
import { withDispatch } from 'Components/HOC/withDispatch';
import { withDispatch } from 'Components/HOC/context';
import Project from './Project';
import Files from './Files';
import { pushStateToStorage, mergeStateFromStorage } from '../../utils/utils';
Expand Down
2 changes: 1 addition & 1 deletion app/views/component/note/Files.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { Input, message, Icon } from 'antd';
import { ipcRenderer } from 'electron';
import { withDispatch } from 'Components/HOC/withDispatch';
import { withDispatch } from 'Components/HOC/context';

import { createFile, renameNote, deletNote, updateNoteDesc, trashBack, updateNoteUploadStatus, UPLOAD_NOTE_ONEDRIVE } from 'Actions/projects';
import { formatDate, pushStateToStorage, mergeStateFromStorage, checkSpecial } from 'Utils/utils';
Expand Down
7 changes: 6 additions & 1 deletion app/views/component/note/Note.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import Loading from '../share/Loading';
import '../../assets/scss/note.scss';

const NoteWorkspace = (props) => {
const { projects, markdown, note, markdownSettings, editorMode, searchStatus, searchResult, exportQueue: { status: exportStatus }, imageHostingConfig } = props;
const { projects, markdown, note, markdownSettings, editorMode, searchStatus, searchResult, exportQueue: { status: exportStatus }, imageHostingConfig, editor } = props;
let projectData;
if (searchStatus === 0) {
projectData = projects;
Expand Down Expand Up @@ -45,6 +45,7 @@ const NoteWorkspace = (props) => {
markdown={markdown}
markdownSettings={markdownSettings}
editorMode={editorMode}
editor={editor}
note={note}
/>
</div>
Expand Down Expand Up @@ -100,6 +101,10 @@ NoteWorkspace.propTypes = {
fileUuid: PropTypes.string.isRequired,
exportStatus: PropTypes.number.isRequired,
}).isRequired,
editor: PropTypes.shape({
fontSize: PropTypes.number.isRequired,
previewFontSize: PropTypes.number.isRequired,
}).isRequired,
markdownSettings: PropTypes.shape({
editorWidth: PropTypes.number.isRequired,
}).isRequired,
Expand Down
2 changes: 1 addition & 1 deletion app/views/component/note/Project.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { Icon, Input, message } from 'antd';
import { ipcRenderer } from 'electron';
import { withDispatch } from 'Components/HOC/withDispatch';
import { withDispatch } from 'Components/HOC/context';
import { createProject, deleteProject, renameProject, trashBack, updateNoteUploadStatus } from 'Actions/projects';
import { beforeSwitchSave, clearMarkdown } from 'Actions/markdown';
import { switchProject, switchFile, clearWorkspace, updateNoteProjectName } from 'Actions/note';
Expand Down
2 changes: 1 addition & 1 deletion app/views/component/note/ToolBar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import PropTypes from 'prop-types';
import { ipcRenderer } from 'electron';
import classnames from 'classnames';
import { Icon, Tooltip, Menu, Dropdown } from 'antd';
import { withDispatch } from 'Components/HOC/withDispatch';
import { withDispatch } from 'Components/HOC/context';
import Search from '../share/search/Search';
import SVGIcon from '../share/SVGIcon';

Expand Down
Loading