提交 64c8d552 编写于 作者: C capricorncd

fix: #25

上级 4fe85e8c
此差异已折叠。
此差异已折叠。
此差异已折叠。
{
"name": "zx-editor",
"version": "2.5.3",
"version": "2.5.4",
"description": "ZxEditor is a HTML5 rich text editor",
"author": "capricorncd",
"github": "https://github.com/capricorncd",
......
......@@ -6,7 +6,7 @@ export default {
/**
* BroadCast
*/
broadcast: {},
// broadcast: {},
/**
* on
......
......@@ -40,7 +40,7 @@ export function handleContent (_this) {
p.innerHTML = '<br>'
$content.appendChild(p)
p.focus()
broadcast.emit('change', 'content', _this)
_this.emit('change', 'content', _this)
_this.$cursorElm = p
} else {
_this.$cursorElm = cursor.getRange()
......@@ -51,7 +51,7 @@ export function handleContent (_this) {
// 删除附件等操作
dom.addEvent($content, 'click', e => {
e.stopPropagation()
broadcast.emit('click', $content, e)
_this.emit('click', $content, e)
// 隐藏emojiModal
_this.emojiModal.hide()
_this.textstyleModal.hide()
......@@ -95,14 +95,14 @@ export function handleContent (_this) {
// focus移除$content placeholder
dom.addEvent($content, 'focus', _ => {
broadcast.emit('focus', $content)
_this.emit('focus', $content)
removeContentClass($content)
})
// 离开编辑输入框时,内容是否为空
// 为空则添加<br>
dom.addEvent($content, 'blur', e => {
broadcast.emit('blur', $content)
_this.emit('blur', $content)
// 存储$curor element
_this.$cursorElm = cursor.getRange()
// 检查$content是否为空
......@@ -125,7 +125,7 @@ export function handleContent (_this) {
// 存储$curor element
_this.$cursorElm = cursor.getRange()
_this.checkCursorPosition()
broadcast.emit('change', 'content', _this)
_this.emit('change', 'content', _this)
}, false)
// 粘贴
......@@ -184,10 +184,10 @@ export function handleContent (_this) {
tmr = null
}, 350)
}
broadcast.emit('paste', $content, {
_this.emit('paste', $content, {
content: pasteStr
})
broadcast.emit('change', 'content', _this)
_this.emit('change', 'content', _this)
}
/**
......@@ -214,7 +214,7 @@ export function handleContent (_this) {
const $newNode = dom.changeTagName($rootNode, 'p')
$content.replaceChild($newNode, $rootNode)
}
broadcast.emit('change', 'content', _this)
_this.emit('change', 'content', _this)
}
}
......@@ -256,14 +256,14 @@ export function handleContent (_this) {
_this.dialog.confirm(`您确定要删除${attachName}吗?`, result => {
if (result) {
if ($parent) {
broadcast.emit('remove-attach', $parent, type)
_this.emit('remove-attach', $parent, type)
// 获取相邻元素
let $sibling = $parent.nextElementSibling || $parent.previousElementSibling
$parent.parentNode.removeChild($parent)
// 移动光标
cursor.setRange($sibling, 0)
}
broadcast.emit('change', 'content', _this)
_this.emit('change', 'content', _this)
}
$parent = null
})
......
......@@ -25,7 +25,7 @@ class ZxDialog {
}
_init () {
this.broadcast = broadcast.broadcast
this.broadcast = {}
}
/**
......
......@@ -48,7 +48,7 @@ class ZxEditor {
// version
this.version = '__VERSION__'
// broadcast
this.broadcast = broadcast.broadcast
this.broadcast = {}
// 初始化dom、参数
initMixin(this, selector, options)
// 初始化 toolbar
......@@ -93,7 +93,7 @@ class ZxEditor {
clearTimeout(tmr)
tmr = null
}, 350)
broadcast.emit('change', 'content', this)
this.emit('change', 'content', this)
}
/**
......@@ -263,7 +263,7 @@ class ZxEditor {
if ($img) {
$img.src = src
$img.removeAttribute('id')
broadcast.emit('change', 'content', this)
this.emit('change', 'content', this)
return true
}
return false
......@@ -366,7 +366,7 @@ class ZxEditor {
// 初始化完成后
this.$cursorElm = this.cursor.getRange()
}
broadcast.emit('change', 'content', this)
this.emit('change', 'content', this)
}
/**
......
......@@ -4,7 +4,7 @@
* 2018-09-18 22:58
*/
import util from './util/index'
import broadcast from './broadcast/index'
// import broadcast from './broadcast/index'
export function initKeyboard (_this) {
/**
* ***************************************************
......@@ -27,7 +27,7 @@ export function initKeyboard (_this) {
}
if (isUpdate) {
_this.resetContentPostion( _this.keyboard.height, _this.toolbarHeight)
broadcast.emit('message', {
_this.emit('message', {
msg: 'Property keyboard has been updated!'
})
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册