Skip to content

Commit 291b5e3

Browse files
committed
Feat: Font size
1 parent 6ce1488 commit 291b5e3

File tree

5 files changed

+54
-44
lines changed

5 files changed

+54
-44
lines changed

package-lock.json

Lines changed: 15 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
"main": "src/index.js",
1010
"homepage": "https://apps.peterjuma.com/noteApp",
1111
"dependencies": {
12-
"@monaco-editor/react": "^4.1.3",
1312
"file-saver": "^2.0.5",
1413
"gh-pages": "^3.1.0",
1514
"github-markdown": "^3.2.0",
@@ -25,10 +24,12 @@
2524
"marked": "^2.0.3",
2625
"react": "17.0.1",
2726
"react-dom": "17.0.1",
27+
"react-input-number": "^5.0.19",
2828
"react-markdown": "^6.0.1",
2929
"react-scripts": "4.0.0",
3030
"react-syntax-highlighter": "^15.4.3",
3131
"remark-gfm": "^1.0.0",
32+
"rsuite": "^4.9.4",
3233
"turndown": "^7.0.0",
3334
"turndown-plugin-gfm": "^1.0.2"
3435
},

src/App.js

Lines changed: 6 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ class App extends Component {
3636
this.handleDownloadNote = this.handleDownloadNote.bind(this);
3737
this.handleSearchNotes = this.handleSearchNotes.bind(this);
3838
this.handleIndexedDB = this.handleIndexedDB.bind(this);
39-
this.handleCopyNote = this.handleCopyNote.bind(this);
4039
this.handleCopyEvent = this.handleCopyEvent.bind(this);
4140
this.handleSortNotes = this.handleSortNotes.bind(this);
4241
this.updateCodeSyntaxHighlighting;
@@ -369,42 +368,7 @@ class App extends Component {
369368
}
370369
}
371370

372-
handleCopyNote(e, content) {
373-
var textArea = document.createElement("textarea");
374-
// Place in top-left corner of screen regardless of scroll position.
375-
textArea.style.position = "fixed";
376-
textArea.style.top = 0;
377-
textArea.style.left = 0;
378-
// Ensure it has a small width and height. Setting to 1px / 1em
379-
// doesn't work as this gives a negative w/h on some browsers.
380-
textArea.style.width = "2em";
381-
textArea.style.height = "2em";
382-
// We don't need padding, reducing the size if it does flash render.
383-
textArea.style.padding = 0;
384-
// Clean up any borders.
385-
textArea.style.border = "none";
386-
textArea.style.outline = "none";
387-
textArea.style.boxShadow = "none";
388-
// Avoid flash of white box if rendered for any reason.
389-
textArea.style.background = "transparent";
390-
textArea.value =
391-
typeof content === "object"
392-
? `## ${content.notetitle}\n${content.notebody}`
393-
: content;
394-
document.body.appendChild(textArea);
395-
textArea.focus();
396-
textArea.select();
397-
try {
398-
var successful = document.execCommand("copy");
399-
} catch (err) {
400-
console.log("Oops, unable to copy");
401-
}
402-
document.body.removeChild(textArea);
403-
}
404-
405-
handleCopyEvent(e) {
406-
e.preventDefault();
407-
var copiedContent = "";
371+
handleCopyEvent(e, copiedContent = "") {
408372
if (typeof window.getSelection != "undefined") {
409373
var sel = window.getSelection();
410374
if (sel.rangeCount) {
@@ -419,7 +383,10 @@ class App extends Component {
419383
copiedContent = document.selection.createRange().htmlText;
420384
}
421385
}
422-
this.handleCopyNote("", html2md.turndown(copiedContent));
386+
387+
e.clipboardData.setData("text/html", copied);
388+
e.clipboardData.setData("text/plain", html2md.turndown(copied));
389+
e.preventDefault();
423390
}
424391

425392
handleSearchNotes(e) {
@@ -483,7 +450,7 @@ class App extends Component {
483450
}}
484451
handleEditNoteBtn={this.handleEditNoteBtn}
485452
handleDeleteNote={this.handleDeleteNote}
486-
handleCopyNote={this.handleCopyNote}
453+
handleCopyEvent={this.handleCopyEvent}
487454
handleDownloadNote={this.handleDownloadNote}
488455
/>
489456
);

src/NoteEditor.js

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,14 @@ import NotePreview from "./NotePreview";
33
import keyCodes from "./KeyCodes";
44
import { html2md, md2html } from "./useMarkDown";
55
import marked from "marked";
6+
import InputNumber from "react-input-number";
67

78
function NoteEditor(props) {
89
var note = props.editNoteData;
10+
11+
// Handle FontSize
12+
const [fontsize, setFontsize] = useState(16);
13+
914
// Set default screen size - full
1015
const [splitscreen, setSplitscreen] = useState(false);
1116
const styles = {
@@ -29,7 +34,7 @@ function NoteEditor(props) {
2934
margin: "0 auto",
3035
width: "100%",
3136
padding: "50px 60px",
32-
fontSize: "16px",
37+
fontSize: `${fontsize}px`,
3338
fontWeight: "400",
3439
overflow: "auto",
3540
lineHeight: "1.45",
@@ -450,6 +455,25 @@ function NoteEditor(props) {
450455
>
451456
<span className="tooltiptext">Strikethrough</span>
452457
</i>
458+
<InputNumber
459+
min={10}
460+
max={48}
461+
step={1}
462+
value={fontsize}
463+
onChange={setFontsize}
464+
style={{
465+
width: "4.2rem",
466+
height: "2.7rem",
467+
borderRadius: "4px 2px 2px 4px",
468+
color: "#292a2b",
469+
padding: "0.1ex 1ex",
470+
border: "1px solid #ccc",
471+
fontWeight: 100,
472+
textShadow: "1px 1px 1px rgba(0, 0, 0, 0.1)",
473+
outline: "none",
474+
}}
475+
/>
476+
453477
<div style={styles.buttons}>
454478
<i
455479
className={screenSize.buttonClass}
@@ -481,8 +505,8 @@ function NoteEditor(props) {
481505
id="notebody"
482506
ref={inputRef}
483507
data-action={note.action}
484-
selectionEnd={cusor.end}
485-
selectionStart={cusor.start}
508+
selectionend={cusor.end}
509+
selectionstart={cusor.start}
486510
style={
487511
toggleState.theme === "vs-light"
488512
? { ...styles.textarea, ...styles.light }

src/styles.css

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,6 @@ h3 {
380380
max-width: 1440px;
381381
margin: 0 auto;
382382
width: 100%;
383-
font-size: 16px;
384383
font-weight: 400;
385384
overflow: auto;
386385
line-height: 1.45;
@@ -591,3 +590,7 @@ button[disabled]:hover {
591590
opacity: 0.6;
592591
font-size: 1.55rem;
593592
}
593+
594+
input[type="number"] {
595+
width: 4rem;
596+
}

0 commit comments

Comments
 (0)