diff --git a/src/js/anot-touch.js b/src/js/anot-touch.js index 4a7a228..c4c6ef1 100644 --- a/src/js/anot-touch.js +++ b/src/js/anot-touch.js @@ -4095,25 +4095,32 @@ const _Anot = (function() { }, update: function(val) { var elem = this.element - var obj = val + var obj = {} var vm = this.vmodels[0] - if (typeof obj === 'object' && obj !== null) { - if (!Anot.isPlainObject(obj)) { - if (Date.isDate(obj)) { - obj = {} - obj[this.param] = val.toUTCString() + if (this.param) { + if (typeof val === 'object' && val !== null) { + if (Array.isArray(val)) { + obj[this.param] = val.$model || val } else { - obj = obj.$model + if (Date.isDate(val)) { + obj[this.param] = val.toUTCString() + } else { + obj[this.param] = val.$model || val + } } + } else { + obj[this.param] = val } } else { - if (!this.param) { + if (!val || typeof val !== 'object' || Array.isArray(val)) { + return + } + if (Date.isDate(val)) { return } - obj = {} - obj[this.param] = val + obj = val.$model || val } for (var i in obj) { diff --git a/src/js/anot-touch.shim.js b/src/js/anot-touch.shim.js index c3df011..77e51af 100644 --- a/src/js/anot-touch.shim.js +++ b/src/js/anot-touch.shim.js @@ -4110,25 +4110,32 @@ }, update: function(val) { var elem = this.element - var obj = val + var obj = {} var vm = this.vmodels[0] - if (typeof obj === 'object' && obj !== null) { - if (!Anot.isPlainObject(obj)) { - if (Date.isDate(obj)) { - obj = {} - obj[this.param] = val.toUTCString() + if (this.param) { + if (typeof val === 'object' && val !== null) { + if (Array.isArray(val)) { + obj[this.param] = val.$model || val } else { - obj = obj.$model + if (Date.isDate(val)) { + obj[this.param] = val.toUTCString() + } else { + obj[this.param] = val.$model || val + } } + } else { + obj[this.param] = val } } else { - if (!this.param) { + if (!val || typeof val !== 'object' || Array.isArray(val)) { + return + } + if (Date.isDate(val)) { return } - obj = {} - obj[this.param] = val + obj = val.$model || val } for (var i in obj) { diff --git a/src/js/anot.js b/src/js/anot.js index 6b25575..668c3e0 100644 --- a/src/js/anot.js +++ b/src/js/anot.js @@ -4095,25 +4095,32 @@ const _Anot = (function() { }, update: function(val) { var elem = this.element - var obj = val + var obj = {} var vm = this.vmodels[0] - if (typeof obj === 'object' && obj !== null) { - if (!Anot.isPlainObject(obj)) { - if (Date.isDate(obj)) { - obj = {} - obj[this.param] = val.toUTCString() + if (this.param) { + if (typeof val === 'object' && val !== null) { + if (Array.isArray(val)) { + obj[this.param] = val.$model || val } else { - obj = obj.$model + if (Date.isDate(val)) { + obj[this.param] = val.toUTCString() + } else { + obj[this.param] = val.$model || val + } } + } else { + obj[this.param] = val } } else { - if (!this.param) { + if (!val || typeof val !== 'object' || Array.isArray(val)) { + return + } + if (Date.isDate(val)) { return } - obj = {} - obj[this.param] = val + obj = val.$model || val } for (var i in obj) { diff --git a/src/js/anot.shim.js b/src/js/anot.shim.js index c1ae689..dfeb88e 100644 --- a/src/js/anot.shim.js +++ b/src/js/anot.shim.js @@ -4110,25 +4110,32 @@ }, update: function(val) { var elem = this.element - var obj = val + var obj = {} var vm = this.vmodels[0] - if (typeof obj === 'object' && obj !== null) { - if (!Anot.isPlainObject(obj)) { - if (Date.isDate(obj)) { - obj = {} - obj[this.param] = val.toUTCString() + if (this.param) { + if (typeof val === 'object' && val !== null) { + if (Array.isArray(val)) { + obj[this.param] = val.$model || val } else { - obj = obj.$model + if (Date.isDate(val)) { + obj[this.param] = val.toUTCString() + } else { + obj[this.param] = val.$model || val + } } + } else { + obj[this.param] = val } } else { - if (!this.param) { + if (!val || typeof val !== 'object' || Array.isArray(val)) { + return + } + if (Date.isDate(val)) { return } - obj = {} - obj[this.param] = val + obj = val.$model || val } for (var i in obj) { diff --git a/src/js/meditor/addon/base.js b/src/js/meditor/addon/base.js index fbda73b..cc56aa2 100644 --- a/src/js/meditor/addon/base.js +++ b/src/js/meditor/addon/base.js @@ -467,6 +467,11 @@ const addon = { }, fullscreen: function() { this.fullscreen = !this.fullscreen + if (this.fullscreen) { + document.body.style.overflow = 'hidden' + } else { + document.body.style.overflow = '' + } if (typeof this.props.onFullscreen === 'function') { this.props.onFullscreen(this.fullscreen) } diff --git a/src/js/meditor/index.js b/src/js/meditor/index.js index 7478c1a..212315f 100644 --- a/src/js/meditor/index.js +++ b/src/js/meditor/index.js @@ -254,12 +254,6 @@ class MEObject { setVal(txt) { this.vm.plainTxt = txt || '' } - show() { - this.vm.editorVisible = true - } - hide() { - this.vm.editorVisible = false - } } Anot.component('meditor', { @@ -267,23 +261,33 @@ Anot.component('meditor', { this.classList.add('do-meditor') this.classList.add('do-meditor__font') - this.setAttribute(':visible', 'editorVisible') this.setAttribute(':css', '{height: height}') - this.setAttribute(':class', '{fullscreen: fullscreen, preview: preview}') - if (props.hasOwnProperty('$show')) { - state.editorVisible = props.$show - delete props.$show + this.setAttribute( + ':class', + '{fullscreen: fullscreen, preview: preview, disabled: disabled}' + ) + + if (props.hasOwnProperty('disabled')) { + state.disabled = true + delete props.disabled } - if (props.height && props.height > 180) { - state.height = props.height + if (props.height) { + if ( + (isFinite(props.height) && props.height > 180) || + /%$/.test(props.height) + ) { + state.height = props.height + } delete props.height } next() }, render: function() { - let toolbar = (this.toolbar || DEFAULT_TOOLBAR).map(it => tool(it)).join('') + let toolbar = (this.props.toolbar || DEFAULT_TOOLBAR) + .map(it => tool(it)) + .join('') - delete this.toolbar + delete this.props.toolbar return `
${toolbar}
@@ -369,7 +373,6 @@ Anot.component('meditor', { disabled: false, //禁用编辑器 fullscreen: false, //是否全屏 preview: true, //是否显示预览 - editorVisible: true, htmlTxt: '', //用于预览渲染 plainTxt: '', //纯md文本 addon // 已有插件 @@ -451,6 +454,9 @@ Anot.component('meditor', { } }, onToolClick: function(name, ev) { + if (this.disabled) { + return + } if (this.addon[name]) { this.addon[name].call(this, ev.target) } else { diff --git a/src/js/meditor/skin/main.scss b/src/js/meditor/skin/main.scss index cf80fb6..c57fe4e 100644 --- a/src/js/meditor/skin/main.scss +++ b/src/js/meditor/skin/main.scss @@ -20,7 +20,10 @@ ::-webkit-scrollbar-thumb {background:nth($cgr, 2);} ::-webkit-scrollbar-thumb:hover {background:nth($cgr, 1);} - + &.disabled{border-color:nth($co, 2); + + &::after {position:absolute;left:0;top:0;z-index:100;width:100%;height:100%;content:"";background:rgba(255, 182, 24, 0.07);} + } .tool-bar {overflow:hidden;position:absolute;top:0;left:0;z-index:99;width:100%;height:41px;padding:0 3px;line-height:40px;border-bottom:1px solid nth($cp, 1);background:#fff;color:nth($cd, 1);text-align:center;font-size:24px;