Skip to content

Commit 66ab0a3

Browse files
committed
添加tinymce 编辑器
1 parent 794fe22 commit 66ab0a3

File tree

3 files changed

+36
-17
lines changed

3 files changed

+36
-17
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
},
1111
"dependencies": {
1212
"@element-plus/icons-vue": "^2.0.6",
13+
"@tinymce/tinymce-vue": "^5.0.0",
1314
"axios": "^0.26.1",
1415
"babel-plugin-transform-remove-console": "^6.9.4",
1516
"core-js": "^3.8.3",

src/main.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ import mavonEditor from 'mavon-editor'
1919
// note 这里引入的css能够全局使用
2020
import 'mavon-editor/dist/css/index.css'
2121

22-
22+
import TinyEditor from '@tinymce/tinymce-vue'
23+
// var Editor = require('@tinymce/tinymce-vue').default;
2324

2425
const app = createApp(App)
2526
//
@@ -50,6 +51,6 @@ app.component('SearchIcon', Search)
5051
app.component('PlusIcon', Plus)
5152
app.component('UserIcon', User)
5253
app.component('LockIcon', Lock)
53-
app.use(router).use(store).use(ElementPlus).use(mavonEditor).mount('#app')
54+
app.use(router).use(store).use(TinyEditor).use(ElementPlus).use(mavonEditor).mount('#app')
5455
// app.use(ElementPlus, { size: 'small', zIndex: 5000 })
5556
// app.mount('#app')

src/views/article/components/ArticleComment.vue

Lines changed: 32 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -31,20 +31,30 @@
3131
</el-button>
3232
</div>
3333
</template>
34-
<div v-hlcode class="comment-body" v-html="comment.mdcontent"></div>
34+
<div v-hlcode class="comment-body" v-html="comment.mdcontent"></div>
3535
</el-card>
3636
<el-divider></el-divider>
3737
<div>
3838
<el-form ref="commentFormRef" :model="commentForm">
3939
<el-form-item prop="content">
40-
<mavon-editor
41-
ref="commentEditor"
42-
class="mavon-edtior-custom-comment"
43-
code-style="vs2015"
44-
placeholder="发表评论,支持markdown语法"
45-
:ishljs="true"
46-
v-model="commentForm.content"
47-
/>
40+
<!-- <mavon-editor-->
41+
<!-- ref="commentEditor"-->
42+
<!-- class="mavon-edtior-custom-comment"-->
43+
<!-- code-style="vs2015"-->
44+
<!-- placeholder="发表评论,支持markdown语法"-->
45+
<!-- :ishljs="true"-->
46+
<!-- v-model="commentForm.content"-->
47+
<!-- />-->
48+
49+
<!--todo tiny editor多个组件是分开加载的比较慢-->
50+
<!-- <tiny-editor-->
51+
<!-- api-key="iuykxb7ohtmpw9c8fboekzycycj1zxhqumwjm73lkm1cu2gl"-->
52+
<!-- :init="{plugins:['wordcount','visualchars']}"-->
53+
<!-- >-->
54+
<!-- </tiny-editor>-->
55+
56+
<!-- <tiny-mce></tiny-mce>-->
57+
4858
</el-form-item>
4959
</el-form>
5060
<div class="comment-status">
@@ -62,10 +72,16 @@
6272
<script>
6373
import {getCommentList, createComment} from "@/api/comment";
6474
import {mapGetters} from 'vuex'
75+
// import TinyEditor from '@tinymce/tinymce-vue'
76+
// import TinyMce from '@/components/TinyMce'
6577
6678
export default {
6779
name: 'ArticleComment',
68-
components: {},
80+
components: {
81+
// TinyEditor: TinyEditor,
82+
// TinyMce:TinyMce
83+
84+
},
6985
props: {
7086
articleId: {
7187
type: Number
@@ -112,9 +128,9 @@
112128
this.commentForm.replied_to = comment.comment_order
113129
content = "> 回复 " + comment.comment_order + "楼 @" + comment.author
114130
if (quoted) {
115-
content = "> 引用 " + comment.comment_order + "楼 @" + comment.author + "\n\n"
131+
content = "> 引用 " + comment.comment_order + "楼 @" + comment.author + "\n\n"
116132
117-
content = content + "<div class='quote-reply'>" + comment.mdcontent + "</div>"
133+
content = content + "<div class='quote-reply'>" + comment.mdcontent + "</div>"
118134
}
119135
120136
this.commentForm.content = content + "\n\n"
@@ -154,10 +170,11 @@
154170
155171
.comment-item {
156172
margin-top: 10px;
157-
padding:5px;
173+
padding: 5px;
158174
159175
160176
}
177+
161178
.comment-body {
162179
padding-left: 30px;
163180
font-size: small;
@@ -180,10 +197,10 @@
180197
181198
182199
blockquote {
183-
padding:0 1em;
200+
padding: 0 1em;
184201
color: black;
185202
border-left: 0.25em solid;
186-
}
203+
}
187204
188205
.comment-status {
189206
text-align: right;

0 commit comments

Comments
 (0)