提交 47567066 authored 作者: 王鹏飞's avatar 王鹏飞

bug fixes

上级 608bbbcd
...@@ -10,7 +10,7 @@ export default { ...@@ -10,7 +10,7 @@ export default {
name: 'VEditor', name: 'VEditor',
props: { props: {
value: { type: String }, value: { type: String },
disabled: { type: Boolean, default: false } disabled: { type: Boolean, default: null }
}, },
data() { data() {
return { return {
...@@ -19,18 +19,18 @@ export default { ...@@ -19,18 +19,18 @@ export default {
} }
}, },
watch: { watch: {
disabled: { value(val) {
immediate: true, if (this.ckEditor.getData() !== val) {
handler(value) { this.ckEditor.setData(val)
if (this.ckEditor && this.ckEditor.instanceReady) {
this.ckEditor.setReadOnly(value)
}
} }
},
disabled(val) {
this.ckEditor.setReadOnly(val)
} }
}, },
methods: { methods: {
createEditor() { createEditor() {
const editor = (this.ckEditor = CKEDITOR.replace(this.textareaElementId, { const config = {
height: 400, height: 400,
uiColor: '#eeeeee', uiColor: '#eeeeee',
filebrowserImageUploadUrl: '/api/ckeditor/img/upload', filebrowserImageUploadUrl: '/api/ckeditor/img/upload',
...@@ -81,7 +81,16 @@ export default { ...@@ -81,7 +81,16 @@ export default {
{ name: 'links', items: ['Link', 'Unlink', 'Anchor'] }, { name: 'links', items: ['Link', 'Unlink', 'Anchor'] },
{ name: 'insert', items: ['Image', 'Table', 'HorizontalRule'] } { name: 'insert', items: ['Image', 'Table', 'HorizontalRule'] }
] ]
})) }
if (this.readOnly !== null) {
config.readOnly = this.readOnly
}
const editor = (this.ckEditor = CKEDITOR.replace(
this.textareaElementId,
config
))
editor.on('instanceReady', () => { editor.on('instanceReady', () => {
const data = this.value const data = this.value
editor.fire('lockSnapshot') editor.fire('lockSnapshot')
......
...@@ -10,7 +10,7 @@ export default { ...@@ -10,7 +10,7 @@ export default {
name: 'VEditor', name: 'VEditor',
props: { props: {
value: { type: String }, value: { type: String },
disabled: { type: Boolean, default: false } disabled: { type: Boolean, default: null }
}, },
data() { data() {
return { return {
...@@ -18,9 +18,19 @@ export default { ...@@ -18,9 +18,19 @@ export default {
ckEditor: null ckEditor: null
} }
}, },
watch: {
value(val) {
if (this.ckEditor.getData() !== val) {
this.ckEditor.setData(val)
}
},
disabled(val) {
this.ckEditor.setReadOnly(val)
}
},
methods: { methods: {
createEditor() { createEditor() {
const editor = (this.ckEditor = CKEDITOR.replace(this.textareaElementId, { const config = {
height: 400, height: 400,
uiColor: '#eeeeee', uiColor: '#eeeeee',
filebrowserImageUploadUrl: '/api/ckeditor/img/upload', filebrowserImageUploadUrl: '/api/ckeditor/img/upload',
...@@ -71,14 +81,23 @@ export default { ...@@ -71,14 +81,23 @@ export default {
{ name: 'links', items: ['Link', 'Unlink', 'Anchor'] }, { name: 'links', items: ['Link', 'Unlink', 'Anchor'] },
{ name: 'insert', items: ['Image', 'Table', 'HorizontalRule'] } { name: 'insert', items: ['Image', 'Table', 'HorizontalRule'] }
] ]
})) }
if (this.readOnly !== null) {
config.readOnly = this.readOnly
}
const editor = (this.ckEditor = CKEDITOR.replace(
this.textareaElementId,
config
))
editor.on('instanceReady', () => { editor.on('instanceReady', () => {
const data = this.value const data = this.value
editor.fire('lockSnapshot') editor.fire('lockSnapshot')
editor.setData(data, { editor.setData(data, {
callback: () => { callback: () => {
editor.setReadOnly(this.disabled)
this.bindEvent() this.bindEvent()
const newData = editor.getData() const newData = editor.getData()
......
...@@ -20,8 +20,9 @@ ...@@ -20,8 +20,9 @@
), function(global) { ), function(global) {
'use strict'; 'use strict';
// existing version for noConflict() // existing version for noConflict()
global = global || {};
var _Base64 = global.Base64; var _Base64 = global.Base64;
var version = "2.5.0"; var version = "2.5.2";
// if node.js and NOT React Native, we use Buffer // if node.js and NOT React Native, we use Buffer
var buffer; var buffer;
if (typeof module !== 'undefined' && module.exports) { if (typeof module !== 'undefined' && module.exports) {
...@@ -48,8 +49,8 @@ ...@@ -48,8 +49,8 @@
: cc < 0x800 ? (fromCharCode(0xc0 | (cc >>> 6)) : cc < 0x800 ? (fromCharCode(0xc0 | (cc >>> 6))
+ fromCharCode(0x80 | (cc & 0x3f))) + fromCharCode(0x80 | (cc & 0x3f)))
: (fromCharCode(0xe0 | ((cc >>> 12) & 0x0f)) : (fromCharCode(0xe0 | ((cc >>> 12) & 0x0f))
+ fromCharCode(0x80 | ((cc >>> 6) & 0x3f)) + fromCharCode(0x80 | ((cc >>> 6) & 0x3f))
+ fromCharCode(0x80 | ( cc & 0x3f))); + fromCharCode(0x80 | ( cc & 0x3f)));
} else { } else {
var cc = 0x10000 var cc = 0x10000
+ (c.charCodeAt(0) - 0xD800) * 0x400 + (c.charCodeAt(0) - 0xD800) * 0x400
...@@ -82,32 +83,21 @@ ...@@ -82,32 +83,21 @@
} : function(b) { } : function(b) {
return b.replace(/[\s\S]{1,3}/g, cb_encode); return b.replace(/[\s\S]{1,3}/g, cb_encode);
}; };
var _encode = buffer ? var _encode = function(u) {
buffer.from && Uint8Array && buffer.from !== Uint8Array.from var isUint8Array = Object.prototype.toString.call(u) === '[object Uint8Array]';
? function (u) { return isUint8Array ? u.toString('base64')
return (u.constructor === buffer.constructor ? u : buffer.from(u)) : btoa(utob(String(u)));
.toString('base64') }
}
: function (u) {
return (u.constructor === buffer.constructor ? u : new buffer(u))
.toString('base64')
}
: function (u) { return btoa(utob(u)) }
;
var encode = function(u, urisafe) { var encode = function(u, urisafe) {
return !urisafe return !urisafe
? _encode(String(u)) ? _encode(u)
: _encode(String(u)).replace(/[+\/]/g, function(m0) { : _encode(String(u)).replace(/[+\/]/g, function(m0) {
return m0 == '+' ? '-' : '_'; return m0 == '+' ? '-' : '_';
}).replace(/=/g, ''); }).replace(/=/g, '');
}; };
var encodeURI = function(u) { return encode(u, true) }; var encodeURI = function(u) { return encode(u, true) };
// decoder stuff // decoder stuff
var re_btou = new RegExp([ var re_btou = /[\xC0-\xDF][\x80-\xBF]|[\xE0-\xEF][\x80-\xBF]{2}|[\xF0-\xF7][\x80-\xBF]{3}/g;
'[\xC0-\xDF][\x80-\xBF]',
'[\xE0-\xEF][\x80-\xBF]{2}',
'[\xF0-\xF7][\x80-\xBF]{3}'
].join('|'), 'g');
var cb_btou = function(cccc) { var cb_btou = function(cccc) {
switch(cccc.length) { switch(cccc.length) {
case 4: case 4:
...@@ -232,3 +222,4 @@ ...@@ -232,3 +222,4 @@
// that's it! // that's it!
return {Base64: global.Base64} return {Base64: global.Base64}
})); }));
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论