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
52a10448
Commit
52a10448
authored
Jul 04, 2014
by
campaign
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修复shift+方向键问题
parent
ee0677b8
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
33 additions
and
18 deletions
+33
-18
editor.js
src/module/editor.js
+4
-0
editor.receiver.js
src/module/editor.receiver.js
+26
-18
editor.selection.js
src/module/editor.selection.js
+3
-0
No files found.
src/module/editor.js
View file @
52a10448
...
...
@@ -93,6 +93,7 @@ KityMinder.registerModule('TextEditModule', function() {
if
(
selectionReadyShow
){
textShape
.
setStyle
(
'cursor'
,
'text'
);
sel
.
clearBaseOffset
();
receiver
.
updateSelection
();
km
.
setStatus
(
'textedit'
);
...
...
@@ -143,6 +144,8 @@ KityMinder.registerModule('TextEditModule', function() {
sel
.
setColor
(
node
.
getStyle
(
'text-selection-color'
));
sel
.
clearBaseOffset
();
node
.
getTextShape
().
setStyle
(
'cursor'
,
'text'
);
receiver
.
updateSelection
();
...
...
@@ -161,6 +164,7 @@ KityMinder.registerModule('TextEditModule', function() {
}
else
{
//当有光标时,要同步选区
if
(
!
sel
.
collapsed
){
sel
.
clearBaseOffset
();
receiver
.
updateContainerRangeBySel
();
}
...
...
src/module/editor.receiver.js
View file @
52a10448
...
...
@@ -145,6 +145,7 @@ Minder.Receiver = kity.createClass('Receiver', {
},
300
);
me
.
km
.
setStatus
(
'textedit'
);
me
.
selection
.
clearBaseOffset
();
}
...
...
@@ -196,31 +197,37 @@ 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
;
}
var
textlength
=
this
.
textShape
.
getContent
().
length
;
if
(
keymap
.
right
==
keyCode
){
var
endOffset
=
this
.
selection
.
endOffset
+
1
;
if
(
e
ndOffset
>
textlength
){
e
ndOffset
=
textlength
;
this
.
selection
.
currentEndOffset
++
;
if
(
this
.
selection
.
currentE
ndOffset
>
textlength
){
this
.
selection
.
currentE
ndOffset
=
textlength
;
}
this
.
selection
.
setEndOffset
(
endOffset
);
}
else
if
(
keymap
.
left
==
keyCode
){
endOffset
=
this
.
selection
.
endOffset
-
1
;
if
(
endOffset
<
0
){
endOffset
=
0
;
}
else
if
(
keymap
.
left
==
keyCode
){
this
.
selection
.
currentEndOffset
--
;
if
(
this
.
selection
.
currentEndOffset
<
0
){
this
.
selection
.
currentEndOffset
=
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
);
}
}
if
(
this
.
selection
.
currentEndOffset
>=
this
.
selection
.
baseOffset
){
this
.
selection
.
setEndOffset
(
this
.
selection
.
currentEndOffset
);
if
(
this
.
selection
.
currentEndOffset
==
this
.
selection
.
baseOffset
){
this
.
selection
.
setStartOffset
(
this
.
selection
.
baseOffset
);
}
}
else
{
this
.
selection
.
setStartOffset
(
this
.
selection
.
currentEndOffset
);
this
.
selection
.
setEndOffset
(
this
.
selection
.
baseOffset
);
}
this
.
updateContainerRangeBySel
();
...
...
@@ -448,7 +455,8 @@ Minder.Receiver = kity.createClass('Receiver', {
endOffset
=
this
.
textData
[
this
.
selection
.
endOffset
],
width
=
0
;
if
(
this
.
selection
.
collapsed
)
{
this
.
selection
.
updateShow
(
startOffset
||
this
.
textData
[
this
.
textData
.
length
-
1
],
1
);
this
.
selection
.
updateShow
(
startOffset
||
this
.
textData
[
this
.
textData
.
length
-
1
],
2
);
return
this
;
}
if
(
!
endOffset
)
{
...
...
src/module/editor.selection.js
View file @
52a10448
...
...
@@ -115,5 +115,8 @@ Minder.Selection = kity.createClass( 'Selection', {
},
isHide
:
function
(){
return
!
this
.
_show
;
},
clearBaseOffset
:
function
(){
this
.
baseOffset
=
this
.
currentEndOffset
=
null
;
}
}
);
\ No newline at end of file
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