添加markdown等

dev_review
yujialong 1 year ago
parent b4765b92fb
commit 1b9a21d642
  1. 31
      package-lock.json
  2. 2
      package.json
  3. BIN
      src/assets/img/mini.jpg
  4. 539
      src/components/quill/index.vue
  5. 2
      src/setting.js
  6. 1813
      src/views/course/contentSettings.vue
  7. 2
      src/views/shop/addProduct/index.vue

31
package-lock.json generated

@ -3474,6 +3474,11 @@
"integrity": "sha512-MsCAG1z9lPdoO/IUMLSBWBSVxVtJ1395VGIQ+Fc2gNdkQ1hNDnQdw3YhA71WJCBW1vdwA0cAnk/DnW6bqoEUYg==", "integrity": "sha512-MsCAG1z9lPdoO/IUMLSBWBSVxVtJ1395VGIQ+Fc2gNdkQ1hNDnQdw3YhA71WJCBW1vdwA0cAnk/DnW6bqoEUYg==",
"dev": true "dev": true
}, },
"cssfilter": {
"version": "0.0.10",
"resolved": "https://registry.npmjs.org/cssfilter/-/cssfilter-0.0.10.tgz",
"integrity": "sha512-FAaLDaplstoRsDR8XGYH51znUN0UY7nMc6Z9/fvE8EXGwvJE9hu7W2vHwx1+bd6gCYnln9nLbzxFTrcO9YQDZw=="
},
"cssnano": { "cssnano": {
"version": "4.1.10", "version": "4.1.10",
"resolved": "https://registry.npmjs.org/cssnano/-/cssnano-4.1.10.tgz", "resolved": "https://registry.npmjs.org/cssnano/-/cssnano-4.1.10.tgz",
@ -6680,12 +6685,8 @@
"highlight.js": { "highlight.js": {
"version": "9.16.2", "version": "9.16.2",
"resolved": "https://registry.npmjs.org/highlight.js/-/highlight.js-9.16.2.tgz", "resolved": "https://registry.npmjs.org/highlight.js/-/highlight.js-9.16.2.tgz",
"integrity": "sha512-feMUrVLZvjy0oC7FVJQcSQRqbBq9kwqnYE4+Kj9ZjbHh3g+BisiPgF49NyQbVLNdrL/qqZr3Ca9yOKwgn2i/tw==" "integrity": "sha512-feMUrVLZvjy0oC7FVJQcSQRqbBq9kwqnYE4+Kj9ZjbHh3g+BisiPgF49NyQbVLNdrL/qqZr3Ca9yOKwgn2i/tw==",
}, "dev": true
"highlight.js-async-webpack": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/highlight.js-async-webpack/-/highlight.js-async-webpack-1.0.4.tgz",
"integrity": "sha1-wGtnv5nwSQRdYrdW5YVbCRLsYWw="
}, },
"hmac-drbg": { "hmac-drbg": {
"version": "1.0.1", "version": "1.0.1",
@ -8086,12 +8087,11 @@
} }
}, },
"mavon-editor": { "mavon-editor": {
"version": "2.7.7", "version": "2.10.4",
"resolved": "https://registry.npmjs.org/mavon-editor/-/mavon-editor-2.7.7.tgz", "resolved": "https://registry.npmjs.org/mavon-editor/-/mavon-editor-2.10.4.tgz",
"integrity": "sha512-lXnYe+dztKepbv8bi2nedRqG/AwyUDF8gmkv9lHD3fpVJ1+pzAS6YILRIryKCvO9qPIOPEThHsda2DxtlzRsZA==", "integrity": "sha512-CFsBLkgt/KZBDg+SJYe2fyYv4zClY149PiwpH0rDAiiP4ae1XNs0GC8nBsoTeipsHcebDLN1QMkt3bUsnMDjQw==",
"requires": { "requires": {
"highlight.js": "^9.11.0", "xss": "^1.0.6"
"highlight.js-async-webpack": "^1.0.4"
} }
}, },
"md5.js": { "md5.js": {
@ -13455,6 +13455,15 @@
"async-limiter": "~1.0.0" "async-limiter": "~1.0.0"
} }
}, },
"xss": {
"version": "1.0.14",
"resolved": "https://registry.npmjs.org/xss/-/xss-1.0.14.tgz",
"integrity": "sha512-og7TEJhXvn1a7kzZGQ7ETjdQVS2UfZyTlsEdDOqvQF7GoxNfY+0YLCzBy1kPdsDDx4QuNAonQPddpsn6Xl/7sw==",
"requires": {
"commander": "^2.20.3",
"cssfilter": "0.0.10"
}
},
"xtend": { "xtend": {
"version": "4.0.2", "version": "4.0.2",
"resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz", "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz",

@ -19,7 +19,7 @@
"file-saver": "^2.0.5", "file-saver": "^2.0.5",
"image-conversion": "^2.1.1", "image-conversion": "^2.1.1",
"js-cookie": "^3.0.1", "js-cookie": "^3.0.1",
"mavon-editor": "^2.6.17", "mavon-editor": "^2.10.4",
"postcss-px2rem": "^0.3.0", "postcss-px2rem": "^0.3.0",
"px2rem-loader": "^0.1.9", "px2rem-loader": "^0.1.9",
"qs": "^6.11.2", "qs": "^6.11.2",

Binary file not shown.

Before

Width:  |  Height:  |  Size: 88 KiB

After

Width:  |  Height:  |  Size: 81 KiB

@ -1,253 +1,322 @@
<template> <template>
<div class="quill" ref="quill" :class="classes"> <div>
<div ref="editor" :style="styles" v-loading="loading"></div> <el-radio-group class="type-radio"
<el-upload v-model="type"
:headers="headers" @change="typeChange">
:action="this.api.fileupload" <el-radio :label="0">富文本</el-radio>
:before-upload="beforeUpload" <el-radio :label="1">markdown</el-radio>
:on-success="editorUploadSuccess" </el-radio-group>
style="display: none">
<el-button class="editorUpload" type="primary">点击上传</el-button> <div v-show="!type"
</el-upload> class="quill"
ref="quill"
:class="classes">
<div ref="editor"
:style="styles"
v-loading="loading"></div>
<el-upload :headers="headers"
:action="this.api.fileupload"
:before-upload="beforeUpload"
:on-success="editorUploadSuccess"
style="display: none">
<el-button class="editorUpload"
type="primary">点击上传</el-button>
</el-upload>
</div> </div>
<mavon-editor class="md"
v-model="mdVal"
v-show="type"
ref="md"
:ishljs="true"
@change="mdChange"
@imgAdd="imgAdd" />
</div>
</template> </template>
<script> <script>
import Quill from 'quill'; import Quill from 'quill';
import 'quill/dist/quill.core.css'; import 'quill/dist/quill.core.css';
import 'quill/dist/quill.snow.css'; import 'quill/dist/quill.snow.css';
import 'quill/dist/quill.bubble.css'; import 'quill/dist/quill.bubble.css';
import toolbarOptions from './options' import toolbarOptions from './options'
import axios from 'axios'
import { mavonEditor } from 'mavon-editor'
import 'mavon-editor/dist/css/index.css'
export default { export default {
name: 'quill', name: 'quill',
props: { components: {
value: { mavonEditor
type: String, },
default: '' props: {
}, value: {
readonly: { type: String,
type: Boolean, default: ''
default:false },
}, readonly: {
toTop: { type: Boolean,
type: Boolean, default: false
default:true },
}, toTop: {
border: { type: Boolean,
type: Boolean, default: true
default:false },
}, border: {
height: { type: Boolean,
type: Number default: false
}, },
minHeight: { height: {
type: Number type: Number
}, },
/* minHeight: {
* 原本的readOnly失效,对比其他项目发现是quill版本不同导致 type: Number
* 使用props传入elseRead = 'true'手动隐藏工具栏 },
*/ /*
elseRead:{ * 原本的readOnly失效,对比其他项目发现是quill版本不同导致
type:String,default:'false' * 使用props传入elseRead = 'true'手动隐藏工具栏
} */
}, elseRead: {
data () { type: String, default: 'false'
return { }
headers: { },
token: sessionStorage.getItem('token') data () {
}, return {
Quill: null, headers: {
currentValue: '', token: sessionStorage.getItem('token')
options: { },
theme: 'snow', type: 0,
bounds: document.body, mdVal: '',
debug: 'warn', Quill: null,
modules: { currentValue: '',
toolbar: { options: {
container: toolbarOptions, theme: 'snow',
handlers: { bounds: document.body,
'image': function (value) { debug: 'warn',
if (value) { modules: {
// iview toolbar: {
document.querySelector('.editorUpload').click() container: toolbarOptions,
} else { handlers: {
this.Quill.format('image', false); 'image': function (value) {
} if (value) {
} // iview
} document.querySelector('.editorUpload').click()
} } else {
}, this.Quill.format('image', false);
placeholder: '',
readOnly: this.readonly
},
loading: false
}
},
computed: {
classes () {
return [
{
'quill-no-border': !this.border
}
];
},
styles () {
let style = {};
if (this.minHeight) {
style.minHeight = `${this.minHeight}px`;
}
if (this.height) {
style.height = `${this.height}px`;
} }
return style; }
},
},
watch: {
value: {
handler (val) {
if (val !== this.currentValue) {
this.currentValue = val;
if (this.Quill) {
this.Quill.pasteHTML(this.value);
}
}
},
immediate: true
} }
}
}, },
created(){ placeholder: '',
}, readOnly: this.readonly
mounted () { },
this.init(); loading: false
// }
if(this.elseRead==='true'){ },
let children = this.$refs.quill.children[0].style computed: {
children.padding = '0' classes () {
children.overflow = 'hidden' return [
children.height = '0' {
children.borderTop = '0' 'quill-no-border': !this.border
}
];
},
styles () {
let style = {};
if (this.minHeight) {
style.minHeight = `${this.minHeight}px`;
}
if (this.height) {
style.height = `${this.height}px`;
}
return style;
},
},
watch: {
value: {
handler (val) {
if (!this.type) {
if (val !== this.currentValue) {
this.currentValue = val;
if (this.Quill) {
this.Quill.pasteHTML(this.value);
} }
}, }
beforeDestroy () { if (!this.mdVal) this.mdVal = val
//
this.Quill = null;
},
methods: {
init () {
const editor = this.$refs.editor;
//
this.Quill = new Quill(editor, this.options);
const ins = this.Quill
//
ins.pasteHTML(this.currentValue);
if(this.toTop){
this.$nextTick(() => {
window.scrollTo(0,0)
})
}
//
ins.on('text-change', (delta, oldDelta, source) => {
const html = this.$refs.editor.children[0].innerHTML;
const text = ins.getText();
const quill = this.Quill;
//
this.currentValue = html;
// v-model
this.$emit('input', html);
//
this.$emit('on-change', { html, text, quill });
});
// quill
ins.on('text-change', (delta, oldDelta, source) => {
this.$emit('on-text-change', delta, oldDelta, source);
});
ins.on('selection-change', (range, oldRange, source) => {
this.$emit('on-selection-change', range, oldRange, source);
});
ins.on('editor-change', (eventName, ...args) => {
this.$emit('on-editor-change', eventName, ...args);
});
//
ins.root.addEventListener('paste', evt => {
if (evt.clipboardData && evt.clipboardData.files && evt.clipboardData.files.length) {
evt.preventDefault();
//
[].forEach.call(evt.clipboardData.files, file => {
if (!file.type.match(/^image\/(gif|jpe?g|a?png|bmp)/i)) {
return
}
const param = new FormData()
param.append('file', file)
// base64
this.$post(this.api.fileupload, param, {
headers: { "Content-Type": "multipart/form-data" }
}).then(res => {
var range = ins.getSelection()
if (range) {
//
ins.insertEmbed(range.index, 'image', res.data.filesResult.fileUrl)
//
ins.setSelection(range.index + 1)
}
}).catch(res => {})
});
}
}, false)
},
beforeUpload(file){
this.loading = true
},
editorUploadSuccess (res) {
//
let quill = this.Quill
//
if (res.data.filesResult.fileUrl) {
//
let lengths;
if ( quill.getSelection() == null){
lengths = 1
}else{
lengths = quill.getSelection().index;
}
// res
quill.insertEmbed(lengths, 'image', res.data.filesResult.fileUrl)
//
quill.setSelection(lengths + 1)
} else {
this.$message.success('图片插入失败')
}
this.loading = false
},
} }
},
immediate: true
} }
</script> },
<style lang="scss" scoped> mounted () {
.quill-no-border{ this.init();
.ql-toolbar.ql-snow{ //
border: none; if (this.elseRead === 'true') {
border-bottom: 1px solid #e8eaec; let children = this.$refs.quill.children[0].style
children.padding = '0'
children.overflow = 'hidden'
children.height = '0'
children.borderTop = '0'
}
},
beforeDestroy () {
//
this.Quill = null;
},
methods: {
//
typeChange (val) {
if (!this.mdVal) this.mdVal = this.value
},
init () {
const editor = this.$refs.editor;
//
this.Quill = new Quill(editor, this.options);
const ins = this.Quill
//
ins.pasteHTML(this.currentValue);
if (this.toTop) {
this.$nextTick(() => {
window.scrollTo(0, 0)
})
}
//
ins.on('text-change', (delta, oldDelta, source) => {
const html = this.$refs.editor.children[0].innerHTML;
const text = ins.getText();
const quill = this.Quill;
//
this.currentValue = html;
// v-model
this.$emit('input', html);
//
this.$emit('on-change', { html, text, quill });
});
// quill
ins.on('text-change', (delta, oldDelta, source) => {
this.$emit('on-text-change', delta, oldDelta, source);
});
ins.on('selection-change', (range, oldRange, source) => {
this.$emit('on-selection-change', range, oldRange, source);
});
ins.on('editor-change', (eventName, ...args) => {
this.$emit('on-editor-change', eventName, ...args);
});
//
ins.root.addEventListener('paste', evt => {
if (evt.clipboardData && evt.clipboardData.files && evt.clipboardData.files.length) {
evt.preventDefault();
//
[].forEach.call(evt.clipboardData.files, file => {
if (!file.type.match(/^image\/(gif|jpe?g|a?png|bmp)/i)) {
return
}
const param = new FormData()
param.append('file', file)
// base64
this.$post(this.api.fileupload, param, {
headers: { "Content-Type": "multipart/form-data" }
}).then(res => {
var range = ins.getSelection()
if (range) {
//
ins.insertEmbed(range.index, 'image', res.data.filesResult.fileUrl)
//
ins.setSelection(range.index + 1)
}
}).catch(res => { })
});
} }
.ql-container.ql-snow{ }, false)
border: none; },
beforeUpload (file) {
this.loading = true
},
// quill
editorUploadSuccess (res) {
//
let quill = this.Quill
//
if (res.data.filesResult.fileUrl) {
//
let lengths;
if (quill.getSelection() == null) {
lengths = 1
} else {
lengths = quill.getSelection().index;
} }
// res
quill.insertEmbed(lengths, 'image', res.data.filesResult.fileUrl)
//
quill.setSelection(lengths + 1)
} else {
this.$message.success('图片插入失败')
}
this.loading = false
},
//
mdChange (val) {
this.$emit('input', val)
},
// markdown
imgAdd (pos, $file) {
let $vm = this.$refs.md
// ..
const formData = new FormData();
formData.append('file', $file);
axios({
url: this.api.fileupload,
method: 'post',
data: formData,
headers: {
token: this.token,
'Content-Type': 'multipart/form-data'
},
}).then((res) => {
$vm.$img2Url(pos, res.data.data.filesResult.fileUrl);
})
},
}
}
</script>
<style lang="scss" scoped>
.type-radio {
margin-bottom: 20px;
}
.quill-no-border {
.ql-toolbar.ql-snow {
border: none;
border-bottom: 1px solid #e8eaec;
} }
.else{ .ql-container.ql-snow {
.ql-toolbar.ql-snow{ border: none;
height: 0;
overflow: hidden;
padding: 0;
border-top: 0;
}
} }
/deep/.ql-snow { }
position: relative; .else {
.ql-tooltip { .ql-toolbar.ql-snow {
position: absolute !important; height: 0;
top: 0 !important; overflow: hidden;
left: -100px !important; padding: 0;
transform: translateY(10px); border-top: 0;
} }
}
/deep/.ql-snow {
position: relative;
.ql-tooltip {
position: absolute !important;
top: 0 !important;
left: -100px !important;
transform: translateY(10px);
} }
}
.md {
max-height: 300px;
}
/deep/.v-note-wrapper .v-note-panel {
min-height: 200px;
}
</style> </style>

@ -11,7 +11,7 @@ if (isDev) {
jumpPath = 'http://192.168.31.125:8087/' // 本地调试-需要启动本地判分点系统 jumpPath = 'http://192.168.31.125:8087/' // 本地调试-需要启动本地判分点系统
host = 'http://121.37.12.51/' host = 'http://121.37.12.51/'
// host = 'https://huorantech.cn/' // host = 'https://huorantech.cn/'
host = 'http://192.168.31.217:9000/'// 榕 // host = 'http://192.168.31.217:9000/'// 榕
// host = 'http://192.168.31.51:9000/'// 赓 // host = 'http://192.168.31.51:9000/'// 赓
} else if (isPro) { } else if (isPro) {
jumpPath = 'https://www.huorantech.cn/judgmentPoint/' jumpPath = 'https://www.huorantech.cn/judgmentPoint/'

File diff suppressed because it is too large Load Diff

@ -889,6 +889,8 @@ export default {
if (e.typeIds && e.typeIds.length) e.typeIds = e.typeIds[0] if (e.typeIds && e.typeIds.length) e.typeIds = e.typeIds[0]
e.mall.interfaceDiagrams = e.mall.interfaceDiagram ? e.mall.interfaceDiagram.split(',') : [] e.mall.interfaceDiagrams = e.mall.interfaceDiagram ? e.mall.interfaceDiagram.split(',') : []
e.mallAnnex.forEach(e => e.name = e.fileName) e.mallAnnex.forEach(e => e.name = e.fileName)
if (e.systemId && e.systemId.split(',').filter(e => e != 12 && e != 13).length) this.isPython = true // python
if (!e.mall.themeId) e.mall.themeId = ''
if (e.mall.appletIcon) this.appletList = [ if (e.mall.appletIcon) this.appletList = [
{ {
name: e.mall.appletIcon, name: e.mall.appletIcon,

Loading…
Cancel
Save