Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
K
kityminder-core
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
吴志俊
kityminder-core
Commits
80f39798
Commit
80f39798
authored
Sep 24, 2014
by
techird
Browse files
Options
Browse Files
Download
Plain Diff
merge
parents
944d01ff
34ffea7b
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
63 additions
and
38 deletions
+63
-38
event.js
src/core/event.js
+4
-0
clipboard.js
src/module/clipboard.js
+3
-3
editor.js
src/module/editor.js
+13
-19
editor.keyboard.js
src/module/editor.keyboard.js
+43
-16
No files found.
src/core/event.js
View file @
80f39798
...
@@ -52,6 +52,10 @@ var MinderEvent = kity.createClass('MindEvent', {
...
@@ -52,6 +52,10 @@ var MinderEvent = kity.createClass('MindEvent', {
else
if
(
"button"
in
this
.
originEvent
)
else
if
(
"button"
in
this
.
originEvent
)
isRightMB
=
this
.
originEvent
.
button
==
2
;
isRightMB
=
this
.
originEvent
.
button
==
2
;
return
isRightMB
;
return
isRightMB
;
},
getKeyCode
:
function
(){
var
evt
=
this
.
originEvent
;
return
evt
.
keyCode
||
evt
.
which
;
}
}
});
});
...
...
src/module/clipboard.js
View file @
80f39798
...
@@ -81,9 +81,9 @@ KityMinder.registerModule( "ClipboardModule", function () {
...
@@ -81,9 +81,9 @@ KityMinder.registerModule( "ClipboardModule", function () {
'paste'
:
PasteCommand
'paste'
:
PasteCommand
},
},
'commandShortcutKeys'
:
{
'commandShortcutKeys'
:
{
'copy'
:
'
ctrl+c
'
,
'copy'
:
'
normal::ctrl+c|
'
,
'cut'
:
'ctrl+x'
,
'cut'
:
'
normal::
ctrl+x'
,
'paste'
:
'ctrl+v'
'paste'
:
'
normal::
ctrl+v'
}
}
};
};
}
);
}
);
\ No newline at end of file
src/module/editor.js
View file @
80f39798
...
@@ -12,7 +12,7 @@ KityMinder.registerModule('TextEditModule', function() {
...
@@ -12,7 +12,7 @@ KityMinder.registerModule('TextEditModule', function() {
//鼠标被点击,并未太抬起时为真
//鼠标被点击,并未太抬起时为真
var
mouseDownStatus
=
false
;
var
mouseDownStatus
=
false
;
var
mouseupTimer
;
var
dblclickEvent
=
false
;
//当前是否有选区存在
//当前是否有选区存在
var
selectionReadyShow
=
false
;
var
selectionReadyShow
=
false
;
...
@@ -128,30 +128,25 @@ KityMinder.registerModule('TextEditModule', function() {
...
@@ -128,30 +128,25 @@ KityMinder.registerModule('TextEditModule', function() {
receiver
.
clear
();
receiver
.
clear
();
},
},
'inputready.keyup'
:
function
(
e
){
'inputready.keyup'
:
function
(){
if
(
sel
.
isHide
()){
if
(
sel
.
isHide
()){
var
me
=
this
;
inputStatusReady
(
this
.
getSelectedNode
());
// setTimeout(function(){
// inputStatusReady(me.getSelectedNode());
// });
}
}
},
},
//当节点选区通过键盘发生变化时,输入状态要准备好
//当节点选区通过键盘发生变化时,输入状态要准备好
'normal.keyup'
:
function
(
e
)
{
'normal.keyup'
:
function
(
e
)
{
var
node
=
this
.
getSelectedNode
();
var
node
=
this
.
getSelectedNode
();
var
keyCode
=
e
.
getKeyCode
();
if
(
node
)
{
if
(
node
)
{
if
(
this
.
isSingleSelect
()
&&
node
.
isSelected
()
&&
!
sel
.
isShow
()
)
{
if
(
this
.
isSingleSelect
()
&&
node
.
isSelected
()
&&
!
sel
.
isShow
()
)
{
var
orgEvt
=
e
.
originEvent
,
var
orgEvt
=
e
.
originEvent
;
keyCode
=
orgEvt
.
keyCode
;
if
(
keymap
.
isSelectedNodeKey
[
keyCode
]
&&
if
(
keymap
.
isSelectedNodeKey
[
keyCode
]
&&
!
orgEvt
.
ctrlKey
&&
!
orgEvt
.
ctrlKey
&&
!
orgEvt
.
metaKey
&&
!
orgEvt
.
metaKey
&&
!
orgEvt
.
shiftKey
&&
!
orgEvt
.
shiftKey
&&
!
orgEvt
.
altKey
)
{
!
orgEvt
.
altKey
)
{
// setTimeout(function(){
inputStatusReady
(
node
);
// inputStatusReady(node);
// })
}
}
}
}
...
@@ -170,17 +165,16 @@ KityMinder.registerModule('TextEditModule', function() {
...
@@ -170,17 +165,16 @@ KityMinder.registerModule('TextEditModule', function() {
sel
.
setColor
(
node
.
getStyle
(
'text-selection-color'
));
sel
.
setColor
(
node
.
getStyle
(
'text-selection-color'
));
// node.getTextShape().setStyle('cursor', 'text');
//必须再次focus,要不不能呼出键盘
//必须再次focus,要不不能呼出键盘
if
(
browser
.
ipad
){
if
(
browser
.
ipad
){
receiver
.
focus
();
receiver
.
focus
();
}
}
mouseupTimer
=
setTimeout
(
function
()
{
setTimeout
(
function
()
{
if
(
dblclickEvent
){
dblclickEvent
=
false
;
return
;
}
sel
.
collapse
(
true
)
sel
.
collapse
(
true
)
.
updatePosition
(
receiver
.
getOffsetByIndex
())
.
updatePosition
(
receiver
.
getOffsetByIndex
())
.
setShow
();
.
setShow
();
...
@@ -238,8 +232,8 @@ KityMinder.registerModule('TextEditModule', function() {
...
@@ -238,8 +232,8 @@ KityMinder.registerModule('TextEditModule', function() {
var
node
=
e
.
getTargetNode
();
var
node
=
e
.
getTargetNode
();
if
(
node
){
if
(
node
){
//
清理mouseup的timer
//
跟mouseup的timeout有冲突,这里做标记处理
clearTimeout
(
mouseupTimer
)
;
dblclickEvent
=
true
;
inputStatusReady
(
node
);
inputStatusReady
(
node
);
...
...
src/module/editor.keyboard.js
View file @
80f39798
...
@@ -12,6 +12,7 @@ Minder.keyboarder = kity.createClass('keyboarder', function(){
...
@@ -12,6 +12,7 @@ Minder.keyboarder = kity.createClass('keyboarder', function(){
this
.
lastMinderNode
=
null
;
this
.
lastMinderNode
=
null
;
this
.
isTypeText
=
false
;
this
.
isTypeText
=
false
;
this
.
_initEvent
();
this
.
_initEvent
();
this
.
isShortcutCopyKey
=
false
;
},
},
//给接受容器绑定事件
//给接受容器绑定事件
_initEvent
:
function
(){
_initEvent
:
function
(){
...
@@ -118,7 +119,7 @@ Minder.keyboarder = kity.createClass('keyboarder', function(){
...
@@ -118,7 +119,7 @@ Minder.keyboarder = kity.createClass('keyboarder', function(){
},
200
);
},
200
);
me
.
km
.
setStatus
(
'textedit'
);
me
.
km
.
setStatus
(
'textedit'
);
},
},
_input
:
function
(
e
){
_input
:
function
(){
var
me
=
this
;
var
me
=
this
;
if
(
browser
.
ipad
)
{
if
(
browser
.
ipad
)
{
setTimeout
(
function
()
{
setTimeout
(
function
()
{
...
@@ -139,7 +140,7 @@ Minder.keyboarder = kity.createClass('keyboarder', function(){
...
@@ -139,7 +140,7 @@ Minder.keyboarder = kity.createClass('keyboarder', function(){
me
.
_handlerEnterkey
();
me
.
_handlerEnterkey
();
e
.
preventDefault
();
e
.
preventDefault
();
return
false
;
return
false
;
}
}
;
case
keymap
.
Tab
:
case
keymap
.
Tab
:
if
(
this
.
selection
.
isShow
()){
if
(
this
.
selection
.
isShow
()){
this
.
re
.
clear
();
this
.
re
.
clear
();
...
@@ -168,7 +169,8 @@ Minder.keyboarder = kity.createClass('keyboarder', function(){
...
@@ -168,7 +169,8 @@ Minder.keyboarder = kity.createClass('keyboarder', function(){
case
keymap
.
Alt
:
case
keymap
.
Alt
:
case
keymap
.
Cmd
:
case
keymap
.
Cmd
:
case
keymap
.
F2
:
case
keymap
.
F2
:
if
(
this
.
selection
.
isHide
()
&&
this
.
km
.
getStatus
()
!=
'textedit'
){
if
(
this
.
selection
.
isHide
()
&&
this
.
km
.
getStatus
()
!=
'textedit'
&&
this
.
km
.
getStatus
()
!=
'inputready'
){
this
.
km
.
setStatus
(
'normal'
);
this
.
km
.
setStatus
(
'normal'
);
return
;
return
;
}
}
...
@@ -183,8 +185,10 @@ Minder.keyboarder = kity.createClass('keyboarder', function(){
...
@@ -183,8 +185,10 @@ Minder.keyboarder = kity.createClass('keyboarder', function(){
88
:
1
,
88
:
1
,
67
:
1
67
:
1
}[
keyCode
]){
}[
keyCode
]){
//修正在cvs方式下_keyup会把节点文字选中
this
.
isShortcutCopyKey
=
true
;
this
.
km
.
setStatus
(
'normal'
);
this
.
km
.
setStatus
(
'normal'
);
return
;
return
;
}
}
...
@@ -193,24 +197,38 @@ Minder.keyboarder = kity.createClass('keyboarder', function(){
...
@@ -193,24 +197,38 @@ Minder.keyboarder = kity.createClass('keyboarder', function(){
setTimeout
(
function
()
{
setTimeout
(
function
()
{
me
.
range
.
updateNativeRange
().
insertNode
(
$
(
'<span>$$_kityminder_bookmark_$$</span>'
)[
0
]);
me
.
range
.
updateNativeRange
().
insertNode
(
$
(
'<span>$$_kityminder_bookmark_$$</span>'
)[
0
]);
me
.
container
.
innerHTML
=
utils
.
unhtml
(
me
.
container
.
textContent
.
replace
(
/
[\u
200b
\t\r\n]
/g
,
''
));
var
brArr
=
[];
var
index
=
me
.
container
.
textContent
.
indexOf
(
'$$_kityminder_bookmark_$$'
);
utils
.
each
(
me
.
container
.
getElementsByTagName
(
'br'
),
function
(
i
,
br
){
me
.
container
.
textContent
=
me
.
container
.
textContent
.
replace
(
'$$_kityminder_bookmark_$$'
,
''
);
brArr
.
push
(
br
);
me
.
range
.
setStart
(
me
.
container
.
firstChild
,
index
).
collapse
(
true
).
select
();
});
utils
.
each
(
brArr
,
function
(
i
,
br
){
var
textNode
=
document
.
createTextNode
(
'
\
n'
);
br
.
parentNode
.
insertBefore
(
textNode
,
br
);
br
.
parentNode
.
removeChild
(
br
);
});
var
textContent
=
me
.
container
.
textContent
.
replace
(
/
[\u
200b
\t\r]
/g
,
''
);
var
index
=
textContent
.
indexOf
(
'$$_kityminder_bookmark_$$'
);
me
.
re
.
setContainerTxt
(
textContent
.
replace
(
'$$_kityminder_bookmark_$$'
,
''
));
me
.
range
.
setStartOffset
(
index
).
collapse
(
true
).
select
();
me
.
_setTextToContainer
(
keyCode
);
me
.
_setTextToContainer
(
keyCode
);
},
10
0
);
},
5
0
);
return
;
return
;
}
}
//剪切
//剪切
if
(
keyCode
==
keymap
.
x
)
{
if
(
keyCode
==
keymap
.
x
)
{
setTimeout
(
function
()
{
setTimeout
(
function
()
{
me
.
_setTextToContainer
(
keyCode
);
me
.
_setTextToContainer
(
keyCode
);
},
10
0
);
},
5
0
);
return
;
return
;
}
}
}
}
this
.
isShortcutCopyKey
=
false
;
//针对不能连续删除做处理
//针对不能连续删除做处理
if
(
keymap
.
Del
==
keyCode
||
keymap
.
Backspace
==
keyCode
)
if
(
keymap
.
Del
==
keyCode
||
keymap
.
Backspace
==
keyCode
)
me
.
_setTextToContainer
(
keyCode
);
me
.
_setTextToContainer
(
keyCode
);
...
@@ -260,6 +278,7 @@ Minder.keyboarder = kity.createClass('keyboarder', function(){
...
@@ -260,6 +278,7 @@ Minder.keyboarder = kity.createClass('keyboarder', function(){
me
.
_setTextToContainer
(
keyCode
);
me
.
_setTextToContainer
(
keyCode
);
return
;
return
;
}
}
if
(
this
.
isTypeText
)
{
if
(
this
.
isTypeText
)
{
me
.
_setTextToContainer
(
keyCode
);
me
.
_setTextToContainer
(
keyCode
);
return
;
return
;
...
@@ -274,25 +293,31 @@ Minder.keyboarder = kity.createClass('keyboarder', function(){
...
@@ -274,25 +293,31 @@ Minder.keyboarder = kity.createClass('keyboarder', function(){
},
},
_keyup
:
function
(
e
){
_keyup
:
function
(
e
){
var
me
=
this
;
var
me
=
this
;
var
orgEvt
=
e
.
originEvent
;
var
timer
;
var
keyCode
=
orgEvt
.
keyCode
;
var
node
=
this
.
km
.
getSelectedNode
();
var
node
=
this
.
km
.
getSelectedNode
();
if
(
this
.
km
.
getStatus
()
==
'normal'
&&
node
&&
this
.
selection
.
isHide
()){
if
(
this
.
km
.
getStatus
()
==
'normal'
&&
node
&&
this
.
selection
.
isHide
()){
if
(
this
.
isShortcutCopyKey
){
console
.
log
(
this
.
km
.
getStatus
())
return
;
}
if
(
node
&&
this
.
km
.
isSingleSelect
()
&&
node
.
isSelected
())
{
if
(
node
&&
this
.
km
.
isSingleSelect
()
&&
node
.
isSelected
())
{
this
.
re
.
updateByMinderNode
(
node
);
this
.
selection
.
setHide
()
this
.
selection
.
setHide
()
.
setStartOffset
(
0
)
.
setStartOffset
(
0
)
.
setEndOffset
(
this
.
re
.
getTxtOfContainer
().
length
)
.
setEndOffset
(
this
.
re
.
getTxtOfContainer
().
length
)
.
setColor
(
node
.
getStyle
(
'text-selection-color'
));
.
setColor
(
node
.
getStyle
(
'text-selection-color'
));
var
re
=
this
.
re
;
setTimeout
(
function
(){
setTimeout
(
function
()
{
me
.
re
.
updateContainerRangeBySel
();
re
.
updateByMinderNode
(
node
).
updateContainerRangeBySel
();
});
});
if
(
browser
.
ie
){
if
(
browser
.
ie
){
var
timer
=
setInterval
(
function
(){
timer
=
setInterval
(
function
(){
var
nativeRange
=
me
.
range
.
nativeSel
.
getRangeAt
(
0
);
var
nativeRange
=
me
.
range
.
nativeSel
.
getRangeAt
(
0
);
if
(
!
nativeRange
||
nativeRange
.
collapsed
){
if
(
!
nativeRange
||
nativeRange
.
collapsed
){
me
.
range
.
select
();
me
.
range
.
select
();
...
@@ -333,6 +358,8 @@ Minder.keyboarder = kity.createClass('keyboarder', function(){
...
@@ -333,6 +358,8 @@ Minder.keyboarder = kity.createClass('keyboarder', function(){
rng
.
setStartBefore
(
br
);
rng
.
setStartBefore
(
br
);
rng
.
collapse
(
true
);
rng
.
collapse
(
true
);
}
}
rng
.
select
();
rng
.
select
();
me
.
_setTextToContainer
(
keymap
.
Enter
);
me
.
_setTextToContainer
(
keymap
.
Enter
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment