Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
易企天创
zui
提交
911f58a2
Z
zui
项目概览
易企天创
/
zui
大约 1 年 前同步成功
通知
6
Star
0
Fork
1
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
37
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Z
zui
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
37
Issue
37
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
911f58a2
编写于
5月 05, 2019
作者:
C
Catouse
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
* finish task
#11
.
上级
21f92050
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
169 addition
and
0 deletion
+169
-0
src/js/kindeditor/plugins/advance-table.js
src/js/kindeditor/plugins/advance-table.js
+169
-0
未找到文件。
src/js/kindeditor/plugins/advance-table.js
浏览文件 @
911f58a2
...
...
@@ -788,6 +788,175 @@ KindEditor.plugin('table', function (K) {
}
return
false
;
});
var
selectRow
=
function
(
$table
,
rowIndex
)
{
$table
.
children
(
'
thead,tbody,tfoot
'
).
children
(
'
tr
'
).
each
(
function
()
{
if
(
this
.
rowIndex
===
rowIndex
)
{
$
(
this
).
children
(
'
td,th
'
).
addClass
(
'
ke-select-cell
'
);
}
});
};
var
selectCol
=
function
(
$table
,
cellIndex
)
{
$table
.
children
(
'
thead,tbody,tfoot
'
).
children
(
'
tr
'
).
children
(
'
td,th
'
).
each
(
function
()
{
if
(
this
.
cellIndex
===
cellIndex
)
{
$
(
this
).
addClass
(
'
ke-select-cell
'
);
}
});
};
var
selectCellsRange
=
function
(
$table
,
startRow
,
startCol
,
endRow
,
endCol
)
{
if
(
startRow
>
endRow
)
{
var
tmp
=
startRow
;
startRow
=
endRow
;
endRow
=
tmp
;
}
if
(
startCol
>
endCol
)
{
var
tmp
=
startCol
;
startCol
=
endCol
;
endCol
=
tmp
;
}
$table
.
children
(
'
thead,tbody,tfoot
'
).
children
(
'
tr
'
).
each
(
function
()
{
var
rowIndex
=
this
.
rowIndex
;
if
(
rowIndex
>=
startRow
&&
rowIndex
<=
endRow
)
{
$
(
this
).
children
(
'
td,th
'
).
each
(
function
()
{
var
colIndex
=
this
.
cellIndex
;
if
(
colIndex
>=
startCol
&&
colIndex
<=
endCol
)
{
$
(
this
).
addClass
(
'
ke-select-cell
'
);
}
});
}
});
};
self
.
afterCreate
(
function
()
{
var
isMouseDown
=
false
;
var
$mouseDownTable
=
null
;
var
$mouseMoveTable
=
null
;
var
mouseMoveRowIndex
=
null
;
var
mouseMoveCellIndex
=
null
;
var
mouseDownRowIndex
=
null
;
var
mouseDownCellIndex
=
null
;
var
handleMouseUp
=
function
()
{
isMouseDown
=
false
;
$mouseDownTable
=
null
;
};
$
(
self
.
edit
.
doc
.
body
).
on
(
'
mousedown.ke
'
+
self
.
uuid
,
'
table
'
,
function
(
e
)
{
var
$table
=
$
(
e
.
currentTarget
);
if
(
!
$table
.
length
)
return
;
var
$cell
=
$
(
e
.
target
).
closest
(
'
td,th
'
);
if
(
!
$cell
.
length
)
return
;
$mouseDownTable
=
$table
;
isMouseDown
=
true
;
mouseDownRowIndex
=
$cell
.
closest
(
'
tr
'
)[
0
].
rowIndex
;
mouseDownCellIndex
=
$cell
[
0
].
cellIndex
;
$
(
self
.
edit
.
doc
).
find
(
'
.ke-select-cell
'
).
removeClass
(
'
ke-select-cell
'
);
}).
on
(
'
mousemove.ke
'
+
self
.
uuid
,
'
table
'
,
function
(
e
)
{
var
$table
=
$
(
e
.
currentTarget
);
if
(
!
$table
.
length
)
return
;
var
$cell
=
$
(
e
.
target
).
closest
(
'
td,th
'
);
$table
.
removeClass
(
'
ke-select-row ke-select-col
'
);
if
(
!
$cell
.
length
)
return
;
mouseMoveRowIndex
=
null
;
mouseMoveCellIndex
=
null
;
if
(
isMouseDown
)
{
e
.
preventDefault
();
if
(
$table
[
0
]
!==
$mouseDownTable
[
0
])
return
;
$
(
self
.
edit
.
doc
).
find
(
'
table
'
).
find
(
'
.ke-select-cell
'
).
removeClass
(
'
ke-select-cell
'
);
selectCellsRange
(
$table
,
mouseDownRowIndex
,
mouseDownCellIndex
,
$cell
.
closest
(
'
tr
'
)[
0
].
rowIndex
,
$cell
[
0
].
cellIndex
);
}
else
{
$mouseMoveTable
=
$table
;
var
tableOffset
=
$table
.
offset
();
var
pageX
=
e
.
pageX
;
var
pageY
=
e
.
pageY
;
var
moveX
=
pageX
-
tableOffset
.
left
;
var
moveY
=
pageY
-
tableOffset
.
top
;
if
(
moveX
<
8
)
{
$table
.
addClass
(
'
ke-select-row
'
);
mouseMoveRowIndex
=
$cell
.
closest
(
'
tr
'
)[
0
].
rowIndex
;
e
.
preventDefault
();
e
.
stopPropagation
();
}
else
if
(
moveY
<
8
)
{
$table
.
addClass
(
'
ke-select-col
'
);
mouseMoveCellIndex
=
$cell
[
0
].
cellIndex
;
e
.
preventDefault
();
e
.
stopPropagation
();
}
}
}).
on
(
'
mouseup.ke
'
+
self
.
uuid
,
function
(
e
)
{
var
$target
=
$
(
e
.
target
);
var
$cell
=
$target
.
closest
(
'
td,th
'
);
if
(
!
$cell
.
length
)
return
;
if
(
typeof
mouseMoveRowIndex
===
'
number
'
)
{
selectRow
(
$mouseMoveTable
,
mouseMoveRowIndex
);
e
.
stopPropagation
();
}
else
if
(
typeof
mouseMoveCellIndex
===
'
number
'
)
{
selectCol
(
$mouseMoveTable
,
mouseMoveCellIndex
);
e
.
stopPropagation
();
}
handleMouseUp
();
}).
on
(
'
paste.ke
'
+
self
.
uuid
+
'
keydown.ke
'
+
self
.
uuid
,
function
()
{
$
(
self
.
edit
.
doc
).
find
(
'
table
'
).
removeClass
(
'
ke-select-row ke-select-col
'
).
find
(
'
.ke-select-cell
'
).
removeClass
(
'
ke-select-cell
'
);
});
$
(
document
).
on
(
'
mouseup.ke
'
+
self
.
uuid
,
function
()
{
handleMouseUp
();
});
$
(
self
.
edit
.
doc
.
head
).
append
([
'
<style>
'
,
'
.ke-select-row {cursor: e-resize; cursor: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUBAMAAAB/pwA+AAAAMFBMVEUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABaPxwLAAAAD3RSTlMAqiTk590pHjjw0cZyAjPTb5hoAAAARUlEQVQI12MgCnAowJmdbjAW7/rPcOHS/3Bh9vgvCSCaR1BQcP9/IxCT8T8IAIVhTKBGuAK4NrhppUBBTCteGqE6hzAAAHccHSlSjBVHAAAAAElFTkSuQmCC) 10 10, auto}
'
,
'
.ke-select-col {cursor: s-resize; cursor: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUBAMAAAB/pwA+AAAAJ1BMVEUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADdEvm1AAAADHRSTlMAqiPfH+Q58dPHcgLUxK6wAAAAUklEQVQI12MgCiyUgjNlDuJlcoOYG8DMDAWZgyxtIBZbjYnMQefjCUAmU8zhOSdtjiqAhJ3PAEEQWC2LzZkzIEGwMFgQKgwShApDBUGGKBDlagAGvBgJQ+z5fwAAAABJRU5ErkJggg==) 10 10, auto}
'
,
'
.ke-select-cell {outline: #b3d4fc 2px solid; outline-offset: -1px;}
'
,
'
</style>
'
,
].
join
(
''
));
var
cmdToggleBack
=
self
.
cmd
.
toggle
;
var
cmdToggle
=
function
(
wrapper
,
map
,
flag
)
{
var
self
=
this
;
if
(
flag
===
undefined
||
flag
===
null
)
{
flag
=
self
.
commonNode
(
map
);
}
if
(
flag
)
{
self
.
remove
(
map
);
}
else
{
self
.
wrap
(
wrapper
);
}
return
self
.
select
();
};
self
.
cmd
.
toggle
=
function
(
wrapper
,
map
)
{
var
range
=
self
.
cmd
.
range
;
if
(
range
&&
range
.
endContainer
)
{
var
$cell
=
$
(
range
.
endContainer
).
closest
(
'
th,td
'
);
if
(
!
$cell
.
length
)
return
;
var
$table
=
$cell
.
closest
(
'
table
'
);
if
(
!
$table
.
length
)
return
;
var
$selectCells
=
$table
.
children
(
'
thead,tbody,tfoot
'
).
children
(
'
tr
'
).
children
(
'
.ke-select-cell
'
);
if
(
$selectCells
.
length
)
{
var
bookmark
=
range
.
createBookmark
(
true
);
range
.
selectNodeContents
(
$cell
[
0
]);
self
.
cmd
.
select
();
var
flag
=
!!
self
.
cmd
.
commonNode
(
map
);
$selectCells
.
each
(
function
()
{
range
.
selectNodeContents
(
this
);
self
.
cmd
.
select
();
cmdToggle
.
call
(
self
.
cmd
,
wrapper
,
map
,
flag
);
});
range
.
moveToBookmark
(
bookmark
);
range
.
selectNodeContents
(
$cell
[
0
]);
self
.
cmd
.
select
();
return
;
}
}
return
cmdToggleBack
.
call
(
self
.
cmd
,
wrapper
,
map
);
};
});
self
.
beforeRemove
(
function
()
{
$
(
self
.
edit
.
doc
.
body
).
off
(
'
.ke
'
+
self
.
uuid
);
$
(
document
).
off
(
'
.ke
'
+
self
.
uuid
);
});
});
KindEditor
.
lang
({
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录