Commit ce7a2469 authored by surmon's avatar surmon
Browse files

Update

parent aee76231
## CHANGELOG
### V3.0.3
1. fix import es module bug
2. add test script
### V3.0.2
1. assign options to ssr.js
......
{
"name": "vue-quill-editor",
"description": "Quill editor component for Vue",
"main": "./dist/vue-quill-editor.min.js",
"main": "./dist/vue-quill-editor.js",
"author": {
"name": "Surmon",
"email": "surmon@foxmail.com",
......
......@@ -3,6 +3,7 @@
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.install = exports.quillEditor = exports.Quill = undefined;
var _quill = require('quill');
......@@ -14,7 +15,7 @@ var _objectAssign2 = _interopRequireDefault(_objectAssign);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var quillEditor = function quillEditor(globalOptions) {
var quillDirective = function quillDirective(globalOptions) {
var getInstanceName = function getInstanceName(el, binding, vnode) {
var instanceName = null;
if (binding.arg) {
......@@ -127,16 +128,17 @@ var quillEditor = function quillEditor(globalOptions) {
};
};
var VueQuillEditor = {
Quill: _quill2.default,
var quillEditor = quillDirective({});
quillEditor: quillEditor({}),
var install = function install(Vue) {
var globalOptions = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
install: function install(Vue) {
var globalOptions = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
Vue.directive('quill', quillEditor(globalOptions));
}
Vue.directive('quill', quillDirective(globalOptions));
};
var VueQuillEditor = { Quill: _quill2.default, quillEditor: quillEditor, install: install };
exports.default = VueQuillEditor;
exports.Quill = _quill2.default;
exports.quillEditor = quillEditor;
exports.install = install;
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("quill"),require("object-assign")):"function"==typeof define&&define.amd?define(["quill","object-assign"],t):"object"==typeof exports?exports.VueQuillEditor=t(require("quill"),require("object-assign")):e.VueQuillEditor=t(e.quill,e["object-assign"])}(this,function(e,t){return function(e){function t(i){if(n[i])return n[i].exports;var o=n[i]={i:i,l:!1,exports:{}};return e[i].call(o.exports,o,o.exports,t),o.l=!0,o.exports}var n={};return t.m=e,t.c=n,t.i=function(e){return e},t.d=function(e,n,i){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:i})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="/",t(t.s=2)}([function(t,n){t.exports=e},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=n(4),o=n.n(i),l=n(6),r=n(5),u=r(o.a,l.a,!1,null,null,null);t.default=u.exports},function(e,t,n){"use strict";function i(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0});var o=n(0),l=i(o),r=n(1),u=i(r),s=window.Quill||l.default,a={Quill:s,quillEditor:u.default,install:function(e,t){t&&(u.default.props.globalOptions.default=function(){return t}),e.component(u.default.name,u.default)}};t.default=a},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.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",!1,"large","huge"]}],[{header:[1,2,3,4,5,6,!1]}],[{color:[]},{background:[]}],[{font:[]}],[{align:[]}],["clean"],["link","image","video"]]},placeholder:"Insert text here ...",readOnly:!1}},function(e,t,n){"use strict";function i(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0});var o=n(0),l=i(o),r=n(7),u=i(r),s=n(3),a=i(s),c=window.Quill||l.default;t.default={name:"quill-editor",data:function(){return{_options:{},_content:"",defaultOptions:a.default}},props:{content:String,value:String,disabled:Boolean,options:{type:Object,required:!1,default:function(){return{}}},globalOptions:{type:Object,required:!1,default:function(){return{}}}},mounted:function(){this.initialize()},beforeDestroy:function(){this.quill=null,delete this.quill},methods:{initialize:function(){var e=this;this.$el&&(this._options=(0,u.default)({},this.defaultOptions,this.globalOptions,this.options),this.quill=new c(this.$refs.editor,this._options),(this.value||this.content)&&this.quill.pasteHTML(this.value||this.content),this.disabled&&this.quill.enable(!1),this.quill.on("selection-change",function(t){t?e.$emit("focus",e.quill):e.$emit("blur",e.quill)}),this.quill.on("text-change",function(t,n,i){var o=e.$refs.editor.children[0].innerHTML,l=e.quill,r=e.quill.getText();"<p><br></p>"===o&&(o=""),e._content=o,e.$emit("input",e._content),e.$emit("change",{html:o,text:r,quill:l})}),this.$emit("ready",this.quill))}},watch:{content:function(e,t){this.quill&&(e&&e!==this._content?(this._content=e,this.quill.pasteHTML(e)):e||this.quill.setText(""))},value:function(e,t){this.quill&&(e&&e!==this._content?(this._content=e,this.quill.pasteHTML(e)):e||this.quill.setText(""))},disabled:function(e,t){this.quill&&this.quill.enable(!e)}}}},function(e,t){e.exports=function(e,t,n,i,o,l){var r,u=e=e||{},s=typeof e.default;"object"!==s&&"function"!==s||(r=e,u=e.default);var a="function"==typeof u?u.options:u;t&&(a.render=t.render,a.staticRenderFns=t.staticRenderFns,a._compiled=!0),n&&(a.functional=!0),o&&(a._scopeId=o);var c;if(l?(c=function(e){e=e||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext,e||"undefined"==typeof __VUE_SSR_CONTEXT__||(e=__VUE_SSR_CONTEXT__),i&&i.call(this,e),e&&e._registeredComponents&&e._registeredComponents.add(l)},a._ssrRegister=c):i&&(c=i),c){var d=a.functional,f=d?a.render:a.beforeCreate;d?(a._injectStyles=c,a.render=function(e,t){return c.call(t),f(e,t)}):a.beforeCreate=f?[].concat(f,c):[c]}return{esModule:r,exports:u,options:a}}},function(e,t,n){"use strict";var i=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",{staticClass:"quill-editor"},[e._t("toolbar"),e._v(" "),n("div",{ref:"editor"})],2)},o=[],l={render:i,staticRenderFns:o};t.a=l},function(e,n){e.exports=t}])});
\ No newline at end of file
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("quill"),require("object-assign")):"function"==typeof define&&define.amd?define(["quill","object-assign"],e):"object"==typeof exports?exports.VueQuillEditor=e(require("quill"),require("object-assign")):t.VueQuillEditor=e(t.quill,t["object-assign"])}(this,function(t,e){return function(t){function e(i){if(n[i])return n[i].exports;var l=n[i]={i:i,l:!1,exports:{}};return t[i].call(l.exports,l,l.exports,e),l.l=!0,l.exports}var n={};return e.m=t,e.c=n,e.i=function(t){return t},e.d=function(t,n,i){e.o(t,n)||Object.defineProperty(t,n,{configurable:!1,enumerable:!0,get:i})},e.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,"a",n),n},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="/",e(e.s=2)}([function(e,n){e.exports=t},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i=n(4),l=n.n(i),o=n(6),u=n(5),r=u(l.a,o.a,!1,null,null,null);e.default=r.exports},function(t,e,n){"use strict";function i(t){return t&&t.__esModule?t:{default:t}}Object.defineProperty(e,"__esModule",{value:!0}),e.install=e.quillEditor=e.Quill=void 0;var l=n(0),o=i(l),u=n(1),r=i(u),s=window.Quill||o.default,a=function(t,e){e&&(r.default.props.globalOptions.default=function(){return e}),t.component(r.default.name,r.default)},d={Quill:s,quillEditor:r.default,install:a};e.default=d,e.Quill=s,e.quillEditor=r.default,e.install=a},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.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",!1,"large","huge"]}],[{header:[1,2,3,4,5,6,!1]}],[{color:[]},{background:[]}],[{font:[]}],[{align:[]}],["clean"],["link","image","video"]]},placeholder:"Insert text here ...",readOnly:!1}},function(t,e,n){"use strict";function i(t){return t&&t.__esModule?t:{default:t}}Object.defineProperty(e,"__esModule",{value:!0});var l=n(0),o=i(l),u=n(7),r=i(u),s=n(3),a=i(s),d=window.Quill||o.default;e.default={name:"quill-editor",data:function(){return{_options:{},_content:"",defaultOptions:a.default}},props:{content:String,value:String,disabled:Boolean,options:{type:Object,required:!1,default:function(){return{}}},globalOptions:{type:Object,required:!1,default:function(){return{}}}},mounted:function(){this.initialize()},beforeDestroy:function(){this.quill=null,delete this.quill},methods:{initialize:function(){var t=this;this.$el&&(this._options=(0,r.default)({},this.defaultOptions,this.globalOptions,this.options),this.quill=new d(this.$refs.editor,this._options),(this.value||this.content)&&this.quill.pasteHTML(this.value||this.content),this.disabled&&this.quill.enable(!1),this.quill.on("selection-change",function(e){e?t.$emit("focus",t.quill):t.$emit("blur",t.quill)}),this.quill.on("text-change",function(e,n,i){var l=t.$refs.editor.children[0].innerHTML,o=t.quill,u=t.quill.getText();"<p><br></p>"===l&&(l=""),t._content=l,t.$emit("input",t._content),t.$emit("change",{html:l,text:u,quill:o})}),this.$emit("ready",this.quill))}},watch:{content:function(t,e){this.quill&&(t&&t!==this._content?(this._content=t,this.quill.pasteHTML(t)):t||this.quill.setText(""))},value:function(t,e){this.quill&&(t&&t!==this._content?(this._content=t,this.quill.pasteHTML(t)):t||this.quill.setText(""))},disabled:function(t,e){this.quill&&this.quill.enable(!t)}}}},function(t,e){t.exports=function(t,e,n,i,l,o){var u,r=t=t||{},s=typeof t.default;"object"!==s&&"function"!==s||(u=t,r=t.default);var a="function"==typeof r?r.options:r;e&&(a.render=e.render,a.staticRenderFns=e.staticRenderFns,a._compiled=!0),n&&(a.functional=!0),l&&(a._scopeId=l);var d;if(o?(d=function(t){t=t||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext,t||"undefined"==typeof __VUE_SSR_CONTEXT__||(t=__VUE_SSR_CONTEXT__),i&&i.call(this,t),t&&t._registeredComponents&&t._registeredComponents.add(o)},a._ssrRegister=d):i&&(d=i),d){var c=a.functional,f=c?a.render:a.beforeCreate;c?(a._injectStyles=d,a.render=function(t,e){return d.call(e),f(t,e)}):a.beforeCreate=f?[].concat(f,d):[d]}return{esModule:u,exports:r,options:a}}},function(t,e,n){"use strict";var i=function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("div",{staticClass:"quill-editor"},[t._t("toolbar"),t._v(" "),n("div",{ref:"editor"})],2)},l=[],o={render:i,staticRenderFns:l};e.a=o},function(t,n){t.exports=e}])});
\ No newline at end of file
{
"name": "vue-quill-editor",
"description": "Quill editor component for Vue",
"version": "3.0.2",
"version": "3.0.3",
"license": "MIT",
"private": false,
"author": {
......
......@@ -9,15 +9,14 @@ import _Quill from 'quill'
import quillEditor from './editor.vue'
const Quill = window.Quill || _Quill
const VueQuillEditor = {
Quill,
quillEditor,
install(Vue, globalOptions) {
if (globalOptions) {
quillEditor.props.globalOptions.default = () => globalOptions
}
Vue.component(quillEditor.name, quillEditor)
const install = function (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 }
......@@ -9,7 +9,7 @@
import Quill from 'quill'
import objectAssign from 'object-assign'
const quillEditor = globalOptions => {
const quillDirective = globalOptions => {
// Get quill instace name in directive
const getInstanceName = (el, binding, vnode) => {
......@@ -155,20 +155,17 @@ const quillEditor = globalOptions => {
}
}
const VueQuillEditor = {
// quillEditor
const quillEditor = quillDirective({})
// Quill
Quill,
// Global quill default options
const install = function (Vue, globalOptions = {}) {
// quillEditor
quillEditor: quillEditor({}),
// Global quill default options
install(Vue, globalOptions = {}) {
// Mount quill directive for Vue global
Vue.directive('quill', quillEditor(globalOptions))
}
// Mount quill directive for Vue global
Vue.directive('quill', quillDirective(globalOptions))
}
const VueQuillEditor = { Quill, quillEditor, install }
export default VueQuillEditor
export { Quill, quillEditor, install }
import Quill from 'quill'
import Vue from 'vue/dist/vue.js'
import VueQuillEditor from '../../../src/index.js'
import VueQuillEditor, { quillEditor, install } from '../../../src/index.js'
import VueQuillEditorSsr from '../../../src/ssr.js'
window.Vue = Vue
......@@ -18,6 +18,12 @@ describe('vue-quill-editor', () => {
placeholder: 'global ssr placeholder'
})
// 测试解构是否成功
it('can get the object in es module', () => {
expect(typeof install).to.deep.equal('function')
expect(typeof quillEditor.methods.initialize).to.deep.equal('function')
})
// 全局安装
describe('Global install spa:component', () => {
it(' - should can get the quill element', done => {
......@@ -201,7 +207,7 @@ describe('vue-quill-editor', () => {
</div>
`,
components: {
'VueQuillEditor': VueQuillEditor.quillEditor
'VueQuillEditor': quillEditor
},
data: {
content: '<p>test content</p>',
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment