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
73960471
Commit
73960471
authored
Jul 03, 2014
by
campaign
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修复光标的方向键问题
parent
46595032
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
64 additions
and
26 deletions
+64
-26
keymap.js
src/core/keymap.js
+7
-0
editor.js
src/module/editor.js
+7
-4
editor.receiver.js
src/module/editor.receiver.js
+44
-6
editor.selection.js
src/module/editor.selection.js
+5
-16
paste.js
src/module/paste.js
+1
-0
No files found.
src/core/keymap.js
View file @
73960471
...
@@ -26,11 +26,18 @@ var keymap = KityMinder.keymap = (function(origin) {
...
@@ -26,11 +26,18 @@ var keymap = KityMinder.keymap = (function(origin) {
'End'
:
35
,
'End'
:
35
,
'Home'
:
36
,
'Home'
:
36
,
'Left'
:
37
,
'Left'
:
37
,
'Up'
:
38
,
'Up'
:
38
,
'Right'
:
39
,
'Right'
:
39
,
'Down'
:
40
,
'Down'
:
40
,
'direction'
:{
37
:
1
,
38
:
1
,
39
:
1
,
40
:
1
},
'Insert'
:
45
,
'Insert'
:
45
,
'Del'
:
46
,
'Del'
:
46
,
...
...
src/module/editor.js
View file @
73960471
...
@@ -139,7 +139,6 @@ KityMinder.registerModule('TextEditModule', function() {
...
@@ -139,7 +139,6 @@ KityMinder.registerModule('TextEditModule', function() {
if
(
node
&&
!
selectionReadyShow
&&
receiver
.
isReady
())
{
if
(
node
&&
!
selectionReadyShow
&&
receiver
.
isReady
())
{
sel
.
collapse
();
sel
.
collapse
();
sel
.
setColor
(
node
.
getStyle
(
'text-selection-color'
));
sel
.
setColor
(
node
.
getStyle
(
'text-selection-color'
));
...
@@ -159,10 +158,14 @@ KityMinder.registerModule('TextEditModule', function() {
...
@@ -159,10 +158,14 @@ KityMinder.registerModule('TextEditModule', function() {
//当选中节点后,输入状态准备
//当选中节点后,输入状态准备
if
(
sel
.
isHide
()){
if
(
sel
.
isHide
()){
inputStatusReady
(
e
.
getTargetNode
());
inputStatusReady
(
e
.
getTargetNode
());
}
else
{
//当有光标时,要同步选区
receiver
.
updateContainerRangeBySel
();
}
}
},
},
'textedit.beforemousemove inputready.beforemousemove'
:
function
(
e
)
{
'textedit.beforemousemove inputready.beforemousemove'
:
function
(
e
)
{
if
(
browser
.
ipad
){
if
(
browser
.
ipad
){
...
@@ -240,9 +243,9 @@ KityMinder.registerModule('TextEditModule', function() {
...
@@ -240,9 +243,9 @@ KityMinder.registerModule('TextEditModule', function() {
km
.
setStatus
(
'normal'
);
km
.
setStatus
(
'normal'
);
receiver
.
clear
();
receiver
.
clear
();
},
},
//
'blur': function() {
'blur'
:
function
()
{
//
receiver.clear();
receiver
.
clear
();
//
},
},
'import'
:
function
()
{
'import'
:
function
()
{
km
.
setStatus
(
'normal'
);
km
.
setStatus
(
'normal'
);
receiver
.
clear
();
receiver
.
clear
();
...
...
src/module/editor.receiver.js
View file @
73960471
...
@@ -162,10 +162,6 @@ Minder.Receiver = kity.createClass('Receiver', {
...
@@ -162,10 +162,6 @@ Minder.Receiver = kity.createClass('Receiver', {
switch
(
keyCode
)
{
switch
(
keyCode
)
{
case
keymap
.
Enter
:
case
keymap
.
Enter
:
case
keymap
.
Tab
:
case
keymap
.
Tab
:
case
keymap
.
left
:
case
keymap
.
right
:
case
keymap
.
up
:
case
keymap
.
down
:
if
(
this
.
selection
.
isShow
()){
if
(
this
.
selection
.
isShow
()){
this
.
clear
();
this
.
clear
();
this
.
km
.
setStatus
(
'inputready'
);
this
.
km
.
setStatus
(
'inputready'
);
...
@@ -176,7 +172,16 @@ Minder.Receiver = kity.createClass('Receiver', {
...
@@ -176,7 +172,16 @@ Minder.Receiver = kity.createClass('Receiver', {
this
.
km
.
fire
(
'contentchange'
);
this
.
km
.
fire
(
'contentchange'
);
}
}
return
;
return
;
case
keymap
.
Shift
:
case
keymap
.
left
:
case
keymap
.
right
:
case
keymap
.
up
:
case
keymap
.
down
:
if
(
this
.
selection
.
isHide
()){
this
.
km
.
setStatus
(
'normal'
);
return
;
}
break
;
// case keymap.Shift:
case
keymap
.
Control
:
case
keymap
.
Control
:
case
keymap
.
Alt
:
case
keymap
.
Alt
:
case
keymap
.
Cmd
:
case
keymap
.
Cmd
:
...
@@ -188,7 +193,40 @@ Minder.Receiver = kity.createClass('Receiver', {
...
@@ -188,7 +193,40 @@ Minder.Receiver = kity.createClass('Receiver', {
}
}
return
;
return
;
}
}
//针对按住shift+方向键进行处理
if
(
orgEvt
.
shiftKey
&&
keymap
.
direction
[
keyCode
]
&&
this
.
selection
.
isShow
()){
var
textlength
=
this
.
textShape
.
getContent
().
length
;
if
(
keymap
.
right
==
keyCode
){
var
endOffset
=
this
.
selection
.
endOffset
+
1
;
if
(
endOffset
>
textlength
){
endOffset
=
textlength
;
}
this
.
selection
.
setEndOffset
(
endOffset
);
}
else
if
(
keymap
.
left
==
keyCode
){
endOffset
=
this
.
selection
.
endOffset
-
1
;
if
(
endOffset
<
0
){
endOffset
=
0
;
}
if
(
endOffset
<=
this
.
selection
.
startOffset
){
if
(
endOffset
==
this
.
selection
.
startOffset
){
this
.
selection
.
setEndOffset
(
endOffset
)
}
else
{
this
.
selection
.
setStartOffset
(
endOffset
)
}
}
else
{
this
.
selection
.
setEndOffset
(
endOffset
);
}
}
this
.
updateContainerRangeBySel
();
this
.
updateSelectionShow
();
e
.
preventDefault
();
return
;
}
if
(
e
.
originEvent
.
ctrlKey
||
e
.
originEvent
.
metaKey
)
{
if
(
e
.
originEvent
.
ctrlKey
||
e
.
originEvent
.
metaKey
)
{
//粘贴
//粘贴
...
@@ -291,7 +329,7 @@ Minder.Receiver = kity.createClass('Receiver', {
...
@@ -291,7 +329,7 @@ Minder.Receiver = kity.createClass('Receiver', {
setContainerStyle
:
function
()
{
setContainerStyle
:
function
()
{
var
textShapeBox
=
this
.
getBaseOffset
(
'paper'
);
var
textShapeBox
=
this
.
getBaseOffset
(
'paper'
);
this
.
container
.
style
.
cssText
=
';left:'
+
(
browser
.
ipad
?
'-'
:
''
)
+
this
.
container
.
style
.
cssText
=
';left:'
+
(
browser
.
ipad
?
'-'
:
''
)
+
textShapeBox
.
x
+
'px;top:'
+
(
textShapeBox
.
y
+
textShapeBox
.
height
*
0.1
)
+
textShapeBox
.
x
+
'px;top:'
+
(
textShapeBox
.
y
+
textShapeBox
.
height
*
0.1
)
+
'px;width:'
+
textShapeBox
.
width
+
'px;height:'
+
textShapeBox
.
height
+
'px;'
;
'px;width:'
+
textShapeBox
.
width
+
'px;height:'
+
textShapeBox
.
height
+
'px;'
;
if
(
!
this
.
selection
.
isShow
())
{
if
(
!
this
.
selection
.
isShow
())
{
...
...
src/module/editor.selection.js
View file @
73960471
...
@@ -5,8 +5,7 @@ Minder.Selection = kity.createClass( 'Selection', {
...
@@ -5,8 +5,7 @@ Minder.Selection = kity.createClass( 'Selection', {
this
.
callBase
();
this
.
callBase
();
this
.
height
=
height
||
20
;
this
.
height
=
height
||
20
;
this
.
setAttr
(
'id'
,
'_kity_selection'
);
this
.
setAttr
(
'id'
,
'_kity_selection'
);
this
.
stroke
(
color
||
'rgb(27,171,255)'
,
width
||
1
);
this
.
width
=
2
;
this
.
width
=
0
;
this
.
fill
(
'rgb(27,171,255)'
);
this
.
fill
(
'rgb(27,171,255)'
);
this
.
setHide
();
this
.
setHide
();
this
.
timer
=
null
;
this
.
timer
=
null
;
...
@@ -18,14 +17,11 @@ Minder.Selection = kity.createClass( 'Selection', {
...
@@ -18,14 +17,11 @@ Minder.Selection = kity.createClass( 'Selection', {
},
},
setColor
:
function
(
color
){
setColor
:
function
(
color
){
this
.
stroke
(
color
);
this
.
fill
(
color
);
this
.
fill
(
color
);
},
},
collapse
:
function
(
toEnd
){
collapse
:
function
(
toEnd
){
// this.stroke( 'rgb(27,171,255)', 1 );
this
.
setOpacity
(
1
);
this
.
setOpacity
(
1
);
this
.
width
=
1
;
this
.
width
=
2
;
this
.
collapsed
=
true
;
this
.
collapsed
=
true
;
if
(
toEnd
){
if
(
toEnd
){
this
.
startOffset
=
this
.
endOffset
;
this
.
startOffset
=
this
.
endOffset
;
...
@@ -45,7 +41,6 @@ Minder.Selection = kity.createClass( 'Selection', {
...
@@ -45,7 +41,6 @@ Minder.Selection = kity.createClass( 'Selection', {
return
this
;
return
this
;
}
}
this
.
collapsed
=
false
;
this
.
collapsed
=
false
;
this
.
stroke
(
'none'
,
0
);
this
.
setOpacity
(
0.5
);
this
.
setOpacity
(
0.5
);
return
this
;
return
this
;
},
},
...
@@ -60,7 +55,7 @@ Minder.Selection = kity.createClass( 'Selection', {
...
@@ -60,7 +55,7 @@ Minder.Selection = kity.createClass( 'Selection', {
return
this
;
return
this
;
}
}
this
.
collapsed
=
false
;
this
.
collapsed
=
false
;
this
.
stroke
(
'none'
,
0
);
//
this.stroke('none',0);
this
.
setOpacity
(
0.5
);
this
.
setOpacity
(
0.5
);
return
this
;
return
this
;
},
},
...
@@ -69,19 +64,13 @@ Minder.Selection = kity.createClass( 'Selection', {
...
@@ -69,19 +64,13 @@ Minder.Selection = kity.createClass( 'Selection', {
this
.
setShowHold
();
this
.
setShowHold
();
}
}
this
.
setPosition
(
offset
).
setWidth
(
width
);
this
.
setPosition
(
offset
).
setWidth
(
width
);
//解决在框选内容时,出现很窄的光标
if
(
width
===
0
){
this
.
setOpacity
(
0
);
}
else
{
this
.
setOpacity
(
0.5
);
}
this
.
bringTop
();
this
.
bringTop
();
return
this
;
return
this
;
},
},
setPosition
:
function
(
offset
)
{
setPosition
:
function
(
offset
)
{
try
{
try
{
this
.
x
=
offset
.
x
;
this
.
x
=
Math
.
round
(
offset
.
x
)
;
this
.
y
=
offset
.
y
;
this
.
y
=
Math
.
round
(
offset
.
y
)
;
}
catch
(
e
)
{
}
catch
(
e
)
{
console
.
log
(
e
);
console
.
log
(
e
);
...
...
src/module/paste.js
View file @
73960471
...
@@ -45,6 +45,7 @@ KityMinder.registerModule( "pasteModule", function () {
...
@@ -45,6 +45,7 @@ KityMinder.registerModule( "pasteModule", function () {
break
;
break
;
case
keys
.
x
:
case
keys
.
x
:
getNodes
(
km
.
getSelectedAncestors
(),
true
);
getNodes
(
km
.
getSelectedAncestors
(),
true
);
km
.
layout
(
300
);
_curstatus
=
true
;
_curstatus
=
true
;
break
;
break
;
case
keys
.
v
:
case
keys
.
v
:
...
...
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