This repository has been archived on 2023-08-30. You can view files and clone it, but cannot push or open issues/pull-requests.
bytedo
/
wcui
Archived
1
0
Fork 0

优化attr指令;优化meditor的配置及样式;修复meditor的toobar配置失效的bug

old
宇天 2018-06-19 21:00:28 +08:00
parent 5a3063596e
commit 08c2b6a96a
7 changed files with 99 additions and 57 deletions

View File

@ -4095,25 +4095,32 @@ const _Anot = (function() {
}, },
update: function(val) { update: function(val) {
var elem = this.element var elem = this.element
var obj = val var obj = {}
var vm = this.vmodels[0] var vm = this.vmodels[0]
if (typeof obj === 'object' && obj !== null) { if (this.param) {
if (!Anot.isPlainObject(obj)) { if (typeof val === 'object' && val !== null) {
if (Date.isDate(obj)) { if (Array.isArray(val)) {
obj = {} obj[this.param] = val.$model || val
} else {
if (Date.isDate(val)) {
obj[this.param] = val.toUTCString() obj[this.param] = val.toUTCString()
} else { } else {
obj = obj.$model obj[this.param] = val.$model || val
} }
} }
} else { } else {
if (!this.param) { obj[this.param] = val
}
} else {
if (!val || typeof val !== 'object' || Array.isArray(val)) {
return
}
if (Date.isDate(val)) {
return return
} }
obj = {} obj = val.$model || val
obj[this.param] = val
} }
for (var i in obj) { for (var i in obj) {

View File

@ -4110,25 +4110,32 @@
}, },
update: function(val) { update: function(val) {
var elem = this.element var elem = this.element
var obj = val var obj = {}
var vm = this.vmodels[0] var vm = this.vmodels[0]
if (typeof obj === 'object' && obj !== null) { if (this.param) {
if (!Anot.isPlainObject(obj)) { if (typeof val === 'object' && val !== null) {
if (Date.isDate(obj)) { if (Array.isArray(val)) {
obj = {} obj[this.param] = val.$model || val
} else {
if (Date.isDate(val)) {
obj[this.param] = val.toUTCString() obj[this.param] = val.toUTCString()
} else { } else {
obj = obj.$model obj[this.param] = val.$model || val
} }
} }
} else { } else {
if (!this.param) { obj[this.param] = val
}
} else {
if (!val || typeof val !== 'object' || Array.isArray(val)) {
return
}
if (Date.isDate(val)) {
return return
} }
obj = {} obj = val.$model || val
obj[this.param] = val
} }
for (var i in obj) { for (var i in obj) {

View File

@ -4095,25 +4095,32 @@ const _Anot = (function() {
}, },
update: function(val) { update: function(val) {
var elem = this.element var elem = this.element
var obj = val var obj = {}
var vm = this.vmodels[0] var vm = this.vmodels[0]
if (typeof obj === 'object' && obj !== null) { if (this.param) {
if (!Anot.isPlainObject(obj)) { if (typeof val === 'object' && val !== null) {
if (Date.isDate(obj)) { if (Array.isArray(val)) {
obj = {} obj[this.param] = val.$model || val
} else {
if (Date.isDate(val)) {
obj[this.param] = val.toUTCString() obj[this.param] = val.toUTCString()
} else { } else {
obj = obj.$model obj[this.param] = val.$model || val
} }
} }
} else { } else {
if (!this.param) { obj[this.param] = val
}
} else {
if (!val || typeof val !== 'object' || Array.isArray(val)) {
return
}
if (Date.isDate(val)) {
return return
} }
obj = {} obj = val.$model || val
obj[this.param] = val
} }
for (var i in obj) { for (var i in obj) {

View File

@ -4110,25 +4110,32 @@
}, },
update: function(val) { update: function(val) {
var elem = this.element var elem = this.element
var obj = val var obj = {}
var vm = this.vmodels[0] var vm = this.vmodels[0]
if (typeof obj === 'object' && obj !== null) { if (this.param) {
if (!Anot.isPlainObject(obj)) { if (typeof val === 'object' && val !== null) {
if (Date.isDate(obj)) { if (Array.isArray(val)) {
obj = {} obj[this.param] = val.$model || val
} else {
if (Date.isDate(val)) {
obj[this.param] = val.toUTCString() obj[this.param] = val.toUTCString()
} else { } else {
obj = obj.$model obj[this.param] = val.$model || val
} }
} }
} else { } else {
if (!this.param) { obj[this.param] = val
}
} else {
if (!val || typeof val !== 'object' || Array.isArray(val)) {
return
}
if (Date.isDate(val)) {
return return
} }
obj = {} obj = val.$model || val
obj[this.param] = val
} }
for (var i in obj) { for (var i in obj) {

View File

@ -467,6 +467,11 @@ const addon = {
}, },
fullscreen: function() { fullscreen: function() {
this.fullscreen = !this.fullscreen this.fullscreen = !this.fullscreen
if (this.fullscreen) {
document.body.style.overflow = 'hidden'
} else {
document.body.style.overflow = ''
}
if (typeof this.props.onFullscreen === 'function') { if (typeof this.props.onFullscreen === 'function') {
this.props.onFullscreen(this.fullscreen) this.props.onFullscreen(this.fullscreen)
} }

View File

@ -254,12 +254,6 @@ class MEObject {
setVal(txt) { setVal(txt) {
this.vm.plainTxt = txt || '' this.vm.plainTxt = txt || ''
} }
show() {
this.vm.editorVisible = true
}
hide() {
this.vm.editorVisible = false
}
} }
Anot.component('meditor', { Anot.component('meditor', {
@ -267,23 +261,33 @@ Anot.component('meditor', {
this.classList.add('do-meditor') this.classList.add('do-meditor')
this.classList.add('do-meditor__font') this.classList.add('do-meditor__font')
this.setAttribute(':visible', 'editorVisible')
this.setAttribute(':css', '{height: height}') this.setAttribute(':css', '{height: height}')
this.setAttribute(':class', '{fullscreen: fullscreen, preview: preview}') this.setAttribute(
if (props.hasOwnProperty('$show')) { ':class',
state.editorVisible = props.$show '{fullscreen: fullscreen, preview: preview, disabled: disabled}'
delete props.$show )
if (props.hasOwnProperty('disabled')) {
state.disabled = true
delete props.disabled
} }
if (props.height && props.height > 180) { if (props.height) {
if (
(isFinite(props.height) && props.height > 180) ||
/%$/.test(props.height)
) {
state.height = props.height state.height = props.height
}
delete props.height delete props.height
} }
next() next()
}, },
render: function() { 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 ` return `
<div class="tool-bar do-fn-noselect">${toolbar}</div> <div class="tool-bar do-fn-noselect">${toolbar}</div>
@ -369,7 +373,6 @@ Anot.component('meditor', {
disabled: false, //禁用编辑器 disabled: false, //禁用编辑器
fullscreen: false, //是否全屏 fullscreen: false, //是否全屏
preview: true, //是否显示预览 preview: true, //是否显示预览
editorVisible: true,
htmlTxt: '', //用于预览渲染 htmlTxt: '', //用于预览渲染
plainTxt: '', //纯md文本 plainTxt: '', //纯md文本
addon // 已有插件 addon // 已有插件
@ -451,6 +454,9 @@ Anot.component('meditor', {
} }
}, },
onToolClick: function(name, ev) { onToolClick: function(name, ev) {
if (this.disabled) {
return
}
if (this.addon[name]) { if (this.addon[name]) {
this.addon[name].call(this, ev.target) this.addon[name].call(this, ev.target)
} else { } else {

View File

@ -20,7 +20,10 @@
::-webkit-scrollbar-thumb {background:nth($cgr, 2);} ::-webkit-scrollbar-thumb {background:nth($cgr, 2);}
::-webkit-scrollbar-thumb:hover {background:nth($cgr, 1);} ::-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; .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;