Skip to content

fix: Refactor dependency on tui-editor to @toast-ui/vue-editor and modify related javascript files #4153

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
2 changes: 2 additions & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
sass_binary_site=https://npm.taobao.org/mirrors/node-sass/
registry=https://registry.npm.taobao.org
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"test:ci": "npm run lint && npm run test:unit"
},
"dependencies": {
"@toast-ui/vue-editor": "^3.2.3",
"axios": "0.18.1",
"clipboard": "2.0.4",
"codemirror": "5.45.0",
Expand All @@ -34,7 +35,6 @@
"screenfull": "4.2.0",
"script-loader": "0.7.2",
"sortablejs": "1.8.4",
"tui-editor": "1.3.3",
"vue": "2.6.10",
"vue-count-to": "1.0.13",
"vue-router": "3.0.2",
Expand Down
21 changes: 1 addition & 20 deletions src/components/MarkdownEditor/default-options.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,6 @@ export default {
usageStatistics: false,
hideModeSwitch: false,
toolbarItems: [
'heading',
'bold',
'italic',
'strike',
'divider',
'hr',
'quote',
'divider',
'ul',
'ol',
'task',
'indent',
'outdent',
'divider',
'table',
'image',
'link',
'divider',
'code',
'codeblock'
['heading', 'bold', 'italic', 'strike'], ['hr', 'quote'], ['ul', 'ol', 'task', 'indent', 'outdent'], ['table', 'image', 'link'], ['code', 'codeblock']
]
}
22 changes: 10 additions & 12 deletions src/components/MarkdownEditor/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,10 @@
</template>

<script>
// deps for editor
import 'codemirror/lib/codemirror.css' // codemirror
import 'tui-editor/dist/tui-editor.css' // editor ui
import 'tui-editor/dist/tui-editor-contents.css' // editor content
import '@toast-ui/editor/dist/toastui-editor.css'

import Editor from 'tui-editor'
import Editor from '@toast-ui/editor'
import defaultOptions from './default-options'

export default {
Expand Down Expand Up @@ -62,8 +60,8 @@ export default {
},
watch: {
value(newValue, preValue) {
if (newValue !== preValue && newValue !== this.editor.getValue()) {
this.editor.setValue(newValue)
if (newValue !== preValue && newValue !== this.editor.getMarkdown()) {
this.editor.setMarkdown(newValue)
}
},
language(val) {
Expand All @@ -90,28 +88,28 @@ export default {
...this.editorOptions
})
if (this.value) {
this.editor.setValue(this.value)
this.editor.setMarkdown(this.value)
}
this.editor.on('change', () => {
this.$emit('input', this.editor.getValue())
this.$emit('input', this.editor.getMarkdown())
})
},
destroyEditor() {
if (!this.editor) return
this.editor.off('change')
this.editor.remove()
this.editor.destroy()
},
setValue(value) {
this.editor.setValue(value)
this.editor.setMarkdown(value)
},
getValue() {
return this.editor.getValue()
return this.editor.getMarkdown()
},
setHtml(value) {
this.editor.setHtml(value)
},
getHtml() {
return this.editor.getHtml()
return this.editor.getHTML()
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/views/components-demo/markdown.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<el-tag class="tag-title">
Customize Toolbar:
</el-tag>
<markdown-editor v-model="content3" :options="{ toolbarItems: ['heading','bold','italic']}" />
<markdown-editor v-model="content3" :options="{ toolbarItems: [['heading','bold','italic']]}" />
</div>

<div class="editor-container">
Expand Down