修复编辑时切换目标导致的bug

This commit is contained in:
YouWei Zhao 2020-05-16 11:21:33 +08:00
parent d4836d492b
commit 7d05e23d4c
2 changed files with 12 additions and 10 deletions

View File

@ -97,14 +97,12 @@ editor_mode = function (editor) {
}
editor_mode.prototype.onmode = function (mode, callback) {
//setTimeout(function(){
if (editor_mode.mode != mode) {
if (mode === 'save') editor_mode.doActionList(editor_mode.mode, editor_mode.actionList, callback);
if (editor_mode.mode === 'nextChange' && mode) editor_mode.showMode(mode);
if (mode !== 'save') editor_mode.mode = mode;
editor_mode.actionList = [];
}
//})
if (editor_mode.mode != mode) {
if (mode === 'save') editor_mode.doActionList(editor_mode.mode, editor_mode.actionList, callback);
if (editor_mode.mode === 'nextChange' && mode) editor_mode.showMode(mode);
if (mode !== 'save') editor_mode.mode = mode;
editor_mode.actionList = [];
}
}
editor_mode.prototype.showMode = function (mode) {

View File

@ -224,8 +224,10 @@ editor_table_wrapper = function (editor) {
var listen = function (guids) {
// 每个叶节点的事件绑定
var tableid = editor.util.guid();
editor.mode.currentTable=tableid;
guids.forEach(function (guid) {
editor.table.guidListen(guid, obj, commentObj)
editor.table.guidListen(guid, tableid, obj, commentObj)
});
}
return { "HTML": outstr.join(''), "guids": guids, "listen": listen };
@ -309,7 +311,7 @@ editor_table_wrapper = function (editor) {
* 监听一个guid对应的表格项
* @param {String} guid
*/
editor_table.prototype.guidListen = function (guid, obj, commentObj) {
editor_table.prototype.guidListen = function (guid, tableid, obj, commentObj) {
// tr>td[title=field]
// >td[title=comment,cobj=cobj:json]
// >td>div>input[value=thiseval]
@ -318,6 +320,7 @@ editor_table_wrapper = function (editor) {
var field = thisTr.children[0].getAttribute('title');
var cobj = JSON.parse(thisTr.children[1].getAttribute('cobj'));
var modeNode = thisTr.parentNode;
thisTr.setAttribute('tableid',tableid)
while (!editor_mode._ids.hasOwnProperty(modeNode.getAttribute('id'))) {
modeNode = modeNode.parentNode;
}
@ -341,6 +344,7 @@ editor_table_wrapper = function (editor) {
*/
editor_table.prototype.onchange = function (guid, obj, commentObj, thisTr, input, field, cobj, modeNode) {
editor_mode.onmode(editor_mode._ids[modeNode.getAttribute('id')]);
if (editor.mode.currentTable!=thisTr.getAttribute('tableid')) return;
var thiseval = null;
if (input.checked != null) input.value = input.checked;
try {