Skip to content

Commit b9f9c9c

Browse files
committed
Messing around with different editors to replace HyperMD for more customization.
1 parent b5348fe commit b9f9c9c

File tree

9 files changed

+526
-96
lines changed

9 files changed

+526
-96
lines changed

package-lock.json

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

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,16 @@
1010
"postinstall": "electron-builder install-app-deps"
1111
},
1212
"dependencies": {
13+
"@toast-ui/vue-editor": "^1.0.4",
1314
"codemirror": "^5.43.0",
1415
"fs-extra": "^7.0.1",
1516
"hypermd": "^0.3.11",
1617
"vue": "^2.5.21",
1718
"vue-class-component": "^6.0.0",
19+
"vue-codemirror": "^4.0.6",
1820
"vue-property-decorator": "^7.0.0",
1921
"vue-router": "^3.0.1",
22+
"vue-showdown": "^2.4.0",
2023
"vuex": "^3.0.1"
2124
},
2225
"devDependencies": {

public/style.css

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,31 @@ body {
1111
border-radius: 5px;
1212
}
1313

14-
#app #home .editor .CodeMirror {
14+
/* .editor .tuieditor .CodeMirror .tui-editor-defaultUI */
15+
#app #home{
1516
font-family: 'Avenir', Helvetica, Arial, sans-serif;
1617
-webkit-font-smoothing: antialiased;
1718
-moz-osx-font-smoothing: grayscale;
1819
color: #2c3e50;
1920
width: 100vw;
2021
height: 88vh;
22+
background:transparent !important;
23+
background-color:transparent !important;
2124
}
2225

26+
.te-editor, .te-ww-container, .editor{
27+
width: 100% !important;
28+
position: absolute;
29+
background:transparent !important;
30+
background-color:transparent !important;
31+
}
32+
33+
34+
.te-toolbar-section, .te-preview, .te-md-splitter{
35+
display: none !important;
36+
}
2337

24-
.CodeMirror {
38+
.CodeMirror .tui-editor-defaultUI{
2539
height: 100%;
2640
}
2741

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<template>
2+
<div class="editor">
3+
<editor
4+
:value="editorText"
5+
:options="editorOptions"
6+
:html="editorHtml"
7+
:visible="editorVisible"
8+
height="500px"
9+
mode="markdown"
10+
previewStyle="vertical"
11+
/>
12+
</div>
13+
</template>
14+
<script lang="ts">
15+
import { codemirror } from 'vue-codemirror';
16+
import 'codemirror/lib/codemirror.css';
17+
import { Component, Prop, Vue, Watch } from "vue-property-decorator";
18+
@Component({
19+
components: {
20+
codemirror
21+
}
22+
})
23+
export default class TuiEditor extends Vue {
24+
data() {
25+
return {
26+
editorText: 'This is initialValue.',
27+
editorOptions: {
28+
hideModeSwitch: true,
29+
toolbarItems:[]
30+
},
31+
editorHtml: '',
32+
editorVisible: true
33+
};
34+
}
35+
onEditorLoad() {
36+
console.log("Test");
37+
}
38+
39+
onEditorFocus() {
40+
// implement your code
41+
}
42+
43+
onEditorBlur() {
44+
// implement your code
45+
}
46+
47+
onEditorChange() {
48+
// implement your code
49+
}
50+
51+
onEditorStateChange() {
52+
// implement your code
53+
}
54+
};
55+
</script>

src/components/Editor.vue

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ import { clearInterval } from "timers";
1111
import { Component, Prop, Vue, Watch } from "vue-property-decorator";
1212
import * as path from "path";
1313
import "hypermd/theme/hypermd-light.css";
14-
import "@/theme/sticky.css";
14+
import "../theme/sticky.css"
15+
import "../theme/dark.css"
1516
import Configuration from "@/utility/Configuration";
1617
1718
@Component
@@ -21,6 +22,9 @@ export default class Editor extends Vue {
2122
private config = this.$store.getters.Config
2223
private filePath = () => this.$store.getters.NotePath
2324
25+
mounted(){
26+
this.NoteUpdate();
27+
}
2428
destroyed() {
2529
document.removeChild(document.getElementsByClassName("CodeMirror")[0])
2630
this.internalEditor = null;

src/components/TUIEditor.vue

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
<template>
2+
<div class="editor">
3+
<editor
4+
:value="editorText"
5+
:options="editorOptions"
6+
:html="editorHtml"
7+
:visible="editorVisible"
8+
height="500px"
9+
mode="markdown"
10+
previewStyle="vertical"
11+
/>
12+
</div>
13+
</template>
14+
<script lang="ts">
15+
import 'tui-editor/dist/tui-editor.css';
16+
import 'tui-editor/dist/tui-editor-contents.css';
17+
import 'codemirror/lib/codemirror.css';
18+
import { Editor } from '@toast-ui/vue-editor';
19+
import { Component, Prop, Vue, Watch } from "vue-property-decorator";
20+
@Component({
21+
components: {
22+
'editor': Editor
23+
}
24+
})
25+
export default class TuiEditor extends Vue {
26+
data() {
27+
return {
28+
editorText: 'This is initialValue.',
29+
editorOptions: {
30+
hideModeSwitch: true,
31+
toolbarItems:[]
32+
},
33+
editorHtml: '',
34+
editorVisible: true
35+
};
36+
}
37+
onEditorLoad() {
38+
console.log("Test");
39+
}
40+
41+
onEditorFocus() {
42+
// implement your code
43+
}
44+
45+
onEditorBlur() {
46+
// implement your code
47+
}
48+
49+
onEditorChange() {
50+
// implement your code
51+
}
52+
53+
onEditorStateChange() {
54+
// implement your code
55+
}
56+
};
57+
</script>

src/theme/dark.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.cm-s-dark .CodeMirror-gutters { background: #2d3033; border-right: 0px; }
2+
.CodeMirror.cm-s-dark { background: #2d3033; color: #fff !important; border-radius: 0px 0px 5px 5px;}
3+
.cm-s-dark, .cm-formatting-list, .cm-formatting-task, .cm-property { color: #fff !important;}
4+
.CodeMirror-line::selection { color: #fff !important;}

src/theme/sticky.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
.cm-s-sticky .CodeMirror-gutters { background: #f1ea99; border-right: 0px; }
2-
.cm-s-sticky.CodeMirror { background: #f1ea99; color: #41323f; border-radius: 0px 0px 5px 5px;}
2+
.CodeMirror.cm-s-sticky { background: #f1ea99; color: #41323f; border-radius: 0px 0px 5px 5px;}

src/views/Home.vue

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,21 +27,22 @@
2727
<i class="fas fa-trash"></i>
2828
</a>
2929
</NavBar>
30-
<Editor v-on:finished="handleClose()" v-on:fileLoaded="setFileName"></Editor>
30+
<TuiEditor v-on:finished="handleClose()" v-on:fileLoaded="setFileName"></TuiEditor>
3131
</div>
3232
</template>
3333

3434
<script lang="ts">
3535
import { Component, Vue, Watch } from "vue-property-decorator";
36-
import Editor from "@/components/Editor.vue"; // @ is an alias to /src
36+
//import Editor from "@/components/Editor.vue"; // @ is an alias to /src
37+
import TuiEditor from "@/components/TUIEditor.vue";
3738
import NavBar from "@/components/NavBar.vue";
3839
import { unlink, writeFile, readdirSync } from "fs";
3940
import * as path from "path";
4041
import Configuration from "@/utility/Configuration";
4142
4243
@Component({
4344
components: {
44-
Editor,
45+
TuiEditor,
4546
NavBar
4647
}
4748
})

0 commit comments

Comments
 (0)