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
3eee7359
Commit
3eee7359
authored
Jul 07, 2014
by
campaign
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修复光标问题
parent
dffc771b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
24 deletions
+30
-24
editor.receiver.js
src/module/editor.receiver.js
+20
-7
editor.selection.js
src/module/editor.selection.js
+10
-17
No files found.
src/module/editor.receiver.js
View file @
3eee7359
...
...
@@ -25,7 +25,7 @@ Minder.Receiver = kity.createClass('Receiver', {
me
.
keyboardEvents
.
call
(
me
,
new
MinderEvent
(
e
.
type
==
'keyup'
?
'beforekeyup'
:
e
.
type
,
e
));
});
}
utils
.
addCssRule
(
'km_receiver_css'
,
' .km_receiver{white-space:nowrap;position:absolute;padding:0;margin:0;word-wrap:break-word;
clip:rect(1em 1em 1em 1em);'
);
//
utils
.
addCssRule
(
'km_receiver_css'
,
' .km_receiver{white-space:nowrap;position:absolute;padding:0;margin:0;word-wrap:break-word;
'
);
//clip:rect(1em 1em 1em 1em);
this
.
km
.
on
(
'inputready.beforekeyup inputready.beforekeydown textedit.beforekeyup textedit.beforekeydown textedit.keypress textedit.paste'
,
utils
.
proxy
(
this
.
keyboardEvents
,
this
));
this
.
timer
=
null
;
this
.
index
=
0
;
...
...
@@ -200,6 +200,10 @@ Minder.Receiver = kity.createClass('Receiver', {
this
.
km
.
setStatus
(
'normal'
);
return
;
}
if
(
!
orgEvt
.
shiftKey
){
this
.
selection
.
baseOffset
=
this
.
selection
.
currentEndOffset
=
null
;
}
break
;
// case keymap.Shift:
case
keymap
.
Control
:
...
...
@@ -215,9 +219,7 @@ Minder.Receiver = kity.createClass('Receiver', {
}
//针对按住shift+方向键进行处理
if
(
orgEvt
.
shiftKey
&&
keymap
.
direction
[
keyCode
]
&&
this
.
selection
.
isShow
()){
if
(
this
.
selection
.
baseOffset
===
null
){
this
.
selection
.
baseOffset
=
this
.
selection
.
startOffset
;
this
.
selection
.
currentEndOffset
=
this
.
selection
.
endOffset
;
}
...
...
@@ -292,9 +294,21 @@ Minder.Receiver = kity.createClass('Receiver', {
case
keymap
.
Enter
:
case
keymap
.
Tab
:
case
keymap
.
F2
:
if
(
browser
.
ipad
){
if
(
this
.
selection
.
isShow
()){
this
.
clear
();
this
.
km
.
setStatus
(
'inputready'
);
clearTimeout
(
me
.
inputTextTimer
);
e
.
preventDefault
();
}
else
{
this
.
km
.
setStatus
(
'normal'
);
this
.
km
.
fire
(
'contentchange'
);
}
restoreTextContent
();
return
;
}
if
(
keymap
.
Enter
==
keyCode
&&
(
this
.
isTypeText
||
browser
.
mac
&&
browser
.
gecko
))
{
setTextToContainer
();
}
if
(
this
.
keydownNode
===
this
.
minderNode
)
{
this
.
rollbackStatus
();
...
...
@@ -305,7 +319,6 @@ Minder.Receiver = kity.createClass('Receiver', {
case
keymap
.
Del
:
case
keymap
.
Backspace
:
case
keymap
.
Spacebar
:
setTextToContainer
();
return
;
}
...
...
@@ -362,7 +375,7 @@ Minder.Receiver = kity.createClass('Receiver', {
setContainerStyle
:
function
()
{
var
textShapeBox
=
this
.
getBaseOffset
(
'screen'
);
this
.
container
.
style
.
cssText
=
';left:'
+
(
browser
.
ipad
?
'-'
:
''
)
+
textShapeBox
.
x
+
'px;top:'
+
(
textShapeBox
.
y
)
+
textShapeBox
.
x
+
'px;top:'
+
(
textShapeBox
.
y
+
20
)
+
'px;width:'
+
textShapeBox
.
width
+
'px;height:'
+
textShapeBox
.
height
+
'px;'
;
return
this
;
...
...
@@ -450,7 +463,7 @@ Minder.Receiver = kity.createClass('Receiver', {
me
.
selection
.
setStartOffset
(
i
);
}
if
(
offset
.
x
<=
v
.
x
+
v
.
width
/
2
)
{
me
.
selection
.
collapse
();
me
.
selection
.
collapse
(
true
);
}
else
{
me
.
selection
.
setEndOffset
(
i
+
((
me
.
selection
.
endOffset
>
i
||
dir
==
1
)
&&
i
!=
me
.
textData
.
length
-
1
?
1
:
0
));
...
...
src/module/editor.selection.js
View file @
3eee7359
...
...
@@ -19,25 +19,22 @@ Minder.Selection = kity.createClass( 'Selection', {
setColor
:
function
(
color
){
this
.
fill
(
color
);
},
collapse
:
function
(
to
End
){
collapse
:
function
(
to
Start
){
this
.
setOpacity
(
1
);
this
.
width
=
2
;
this
.
collapsed
=
true
;
if
(
toEnd
){
this
.
startOffset
=
this
.
endOffset
;
}
else
{
if
(
toStart
){
this
.
endOffset
=
this
.
startOffset
;
}
else
{
this
.
startOffset
=
this
.
endOffset
;
}
return
this
;
},
setStartOffset
:
function
(
offset
){
this
.
startOffset
=
offset
;
var
tmpOffset
=
this
.
startOffset
;
if
(
this
.
startOffset
>
this
.
endOffset
){
this
.
startOffset
=
this
.
endOffset
;
this
.
endOffset
=
tmpOffset
;
}
else
if
(
this
.
startOffset
==
this
.
endOffset
){
this
.
collapse
();
if
(
this
.
startOffset
>=
this
.
endOffset
){
this
.
collapse
(
true
);
return
this
;
}
this
.
collapsed
=
false
;
...
...
@@ -46,16 +43,12 @@ Minder.Selection = kity.createClass( 'Selection', {
},
setEndOffset
:
function
(
offset
){
this
.
endOffset
=
offset
;
var
tmpOffset
=
this
.
endOffset
;
if
(
this
.
endOffset
<
this
.
startOffset
){
this
.
endOffset
=
this
.
startOffset
;
this
.
startOffset
=
tmpOffset
;
}
else
if
(
this
.
startOffset
==
this
.
endOffset
){
this
.
collapse
();
if
(
this
.
endOffset
<=
this
.
startOffset
){
this
.
startOffset
=
offset
;
this
.
collapse
(
true
);
return
this
;
}
this
.
collapsed
=
false
;
// this.stroke('none',0);
this
.
setOpacity
(
0.5
);
return
this
;
},
...
...
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