视频会议

This commit is contained in:
wangqiong
2024-01-18 10:46:33 +08:00
parent d7f5ce05ea
commit 37a88df277
28922 changed files with 2797396 additions and 19461 deletions
BIN
View File
Binary file not shown.
+153
View File
@@ -0,0 +1,153 @@
<template>
<div class="quill-editor">
<slot name="toolbar"></slot>
<div ref="editor"></div>
</div>
</template>
<script>
// require sources
import _Quill from 'quill'
import defaultOptions from './options'
const Quill = window.Quill || _Quill
// pollfill
if (typeof Object.assign != 'function') {
Object.defineProperty(Object, 'assign', {
value(target, varArgs) {
if (target == null) {
throw new TypeError('Cannot convert undefined or null to object')
}
const to = Object(target)
for (let index = 1; index < arguments.length; index++) {
const nextSource = arguments[index]
if (nextSource != null) {
for (const nextKey in nextSource) {
if (Object.prototype.hasOwnProperty.call(nextSource, nextKey)) {
to[nextKey] = nextSource[nextKey]
}
}
}
}
return to
},
writable: true,
configurable: true
})
}
// export
export default {
name: 'quill-editor',
data() {
return {
_options: {},
_content: '',
defaultOptions
}
},
props: {
content: String,
value: String,
disabled: {
type: Boolean,
default: false
},
options: {
type: Object,
required: false,
default: () => ({})
},
globalOptions: {
type: Object,
required: false,
default: () => ({})
}
},
mounted() {
this.initialize()
},
beforeDestroy() {
this.quill = null
delete this.quill
},
methods: {
// Init Quill instance
initialize() {
if (this.$el) {
// Options
this._options = Object.assign({}, this.defaultOptions, this.globalOptions, this.options)
// Instance
this.quill = new Quill(this.$refs.editor, this._options)
this.quill.enable(false)
// Set editor content
if (this.value || this.content) {
this.quill.pasteHTML(this.value || this.content)
}
// Disabled editor
if (!this.disabled) {
this.quill.enable(true)
}
// Mark model as touched if editor lost focus
this.quill.on('selection-change', range => {
if (!range) {
this.$emit('blur', this.quill)
} else {
this.$emit('focus', this.quill)
}
})
// Update model if text changes
this.quill.on('text-change', (delta, oldDelta, source) => {
let html = this.$refs.editor.children[0].innerHTML
const quill = this.quill
const text = this.quill.getText()
if (html === '<p><br></p>') html = ''
this._content = html
this.$emit('input', this._content)
this.$emit('change', { html, text, quill })
})
// Emit ready event
this.$emit('ready', this.quill)
}
}
},
watch: {
// Watch content change
content(newVal, oldVal) {
if (this.quill) {
if (newVal && newVal !== this._content) {
this._content = newVal
this.quill.pasteHTML(newVal)
} else if(!newVal) {
this.quill.setText('')
}
}
},
// Watch content change
value(newVal, oldVal) {
if (this.quill) {
if (newVal && newVal !== this._content) {
this._content = newVal
this.quill.pasteHTML(newVal)
} else if(!newVal) {
this.quill.setText('')
}
}
},
// Watch disabled change
disabled(newVal, oldVal) {
if (this.quill) {
this.quill.enable(!newVal)
}
}
}
}
</script>
+22
View File
@@ -0,0 +1,22 @@
/*
* Vue-Quill-Editor index.js
* Author: surmon@foxmail.com
* Github: https://github.com/surmon-china/vue-quill-editor
*/
import _Quill from 'quill'
import quillEditor from './editor.vue'
const Quill = window.Quill || _Quill
const install = (Vue, globalOptions) => {
if (globalOptions) {
quillEditor.props.globalOptions.default = () => globalOptions
}
Vue.component(quillEditor.name, quillEditor)
}
const VueQuillEditor = { Quill, quillEditor, install }
export default VueQuillEditor
export { Quill, quillEditor, install }
+25
View File
@@ -0,0 +1,25 @@
export default {
theme: 'snow',
boundary: document.body,
modules: {
toolbar: [
['bold', 'italic', 'underline', 'strike'],
['blockquote', 'code-block'],
[{ 'header': 1 }, { 'header': 2 }],
[{ 'list': 'ordered' }, { 'list': 'bullet' }],
[{ 'script': 'sub' }, { 'script': 'super' }],
[{ 'indent': '-1' }, { 'indent': '+1' }],
[{ 'direction': 'rtl' }],
[{ 'size': ['small', false, 'large', 'huge'] }],
[{ 'header': [1, 2, 3, 4, 5, 6, false] }],
[{ 'color': [] }, { 'background': [] }],
[{ 'font': [] }],
[{ 'align': [] }],
['clean'],
['link', 'image', 'video']
]
},
placeholder: 'Insert text here ...',
readOnly: false
}
+171
View File
@@ -0,0 +1,171 @@
/*
* vue-quill-editor ssr.js
* Author: surmon@foxmail.com
* Github: https://github.com/surmon-china/vue-quill-editor
*/
// Require sources
import Quill from 'quill'
import objectAssign from 'object-assign'
const quillDirective = globalOptions => {
// Get quill instace name in directive
const getInstanceName = (el, binding, vnode) => {
let instanceName = null
if (binding.arg) {
instanceName = binding.arg
} else if (vnode.data.attrs && (vnode.data.attrs.instanceName || vnode.data.attrs['instance-name'])) {
instanceName = (vnode.data.attrs.instanceName || vnode.data.attrs['instance-name'])
} else if (el.id) {
instanceName = el.id
}
return instanceName || 'quill'
}
return {
inserted(el, binding, vnode) {
const self = vnode.context
const options = binding.value || {}
const instanceName = getInstanceName(el, binding, vnode)
let quill = self[instanceName]
// Emit event in Vue directive
const eventEmit = (vnode, name, data) => {
const handlers = (vnode.data && vnode.data.on) ||
(vnode.componentOptions && vnode.componentOptions.listeners)
if (handlers && handlers[name]) handlers[name].fns(data)
}
// Initialize quill options
if (!quill) {
// Options
const quillOptions = objectAssign({}, {
theme: 'snow',
boundary: document.body,
modules: {
toolbar: [
['bold', 'italic', 'underline', 'strike'],
['blockquote', 'code-block'],
[{ 'header': 1 }, { 'header': 2 }],
[{ 'list': 'ordered' }, { 'list': 'bullet' }],
[{ 'script': 'sub' }, { 'script': 'super' }],
[{ 'indent': '-1' }, { 'indent': '+1' }],
[{ 'direction': 'rtl' }],
[{ 'size': ['small', false, 'large', 'huge'] }],
[{ 'header': [1, 2, 3, 4, 5, 6, false] }],
[{ 'color': [] }, { 'background': [] }],
[{ 'font': [] }],
[{ 'align': [] }],
['clean'],
['link', 'image', 'video']
]
},
placeholder: 'Insert text here ...',
readOnly: false
}, globalOptions, options)
// Instance
quill = self[instanceName] = new Quill(el, quillOptions)
// Data init
const model = vnode.data.model
const _value = vnode.data.attrs ? vnode.data.attrs.value : null
const _content = vnode.data.attrs ? vnode.data.attrs.content : null
const disabled = vnode.data.attrs ? vnode.data.attrs.disabled : null
const content = model ? model.value : (_value || _content)
// Set editor content
if (content) {
quill.pasteHTML(content)
}
// Disabled editor
if (disabled) {
quill.enable(false)
}
// Mark model as touched if editor lost focus
quill.on('selection-change', range => {
if (!range) {
eventEmit(vnode, 'blur', quill)
} else {
eventEmit(vnode, 'focus', quill)
}
})
// Update model if text changes
quill.on('text-change', (delta, oldDelta, source) => {
let html = el.children[0].innerHTML
const text = quill.getText()
if (html === '<p><br></p>') {
html = ''
quill.root.innerHTML = html
}
if (model) {
model.callback(html)
}
eventEmit(vnode, 'input', html)
eventEmit(vnode, 'change', { text, html, quill })
})
// Emit ready event
eventEmit(vnode, 'ready', quill)
}
},
// Parse text model change
componentUpdated(el, binding, vnode) {
const self = vnode.context
const instanceName = getInstanceName(el, binding, vnode)
const options = binding.value || {}
const quill = self[instanceName]
if (quill) {
const model = vnode.data.model
const _value = vnode.data.attrs ? vnode.data.attrs.value : null
const _content = vnode.data.attrs ? vnode.data.attrs.content : null
const disabled = vnode.data.attrs ? vnode.data.attrs.disabled : null
const content = model ? model.value : (_value || _content)
const newData = content
const oldData = el.children[0].innerHTML
quill.enable(!disabled)
if (newData) {
if (newData != oldData) {
const range = quill.getSelection()
quill.root.innerHTML = newData
setTimeout(() => {
quill.setSelection(range)
})
}
} else {
quill.setText('')
}
}
},
// Destroy this directive
unbind(el, binding, vnode) {
if (vnode.context[binding.arg]) {
vnode.context[binding.arg] = null
delete vnode.context[binding.arg]
}
}
}
}
// quillEditor
const quillEditor = quillDirective({})
// Global quill default options
const install = function (Vue, globalOptions = {}) {
// Mount quill directive for Vue global
Vue.directive('quill', quillDirective(globalOptions))
}
const VueQuillEditor = { Quill, quillEditor, install }
export default VueQuillEditor
export { Quill, quillEditor, install }