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

bug fixes

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