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
06027381
Commit
06027381
authored
Feb 21, 2014
by
campaign
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
by zhanyi
parent
422b339d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
12 deletions
+33
-12
editor.js
src/module/editor.js
+21
-6
editor.selection.js
src/module/editor.selection.js
+12
-6
No files found.
src/module/editor.js
View file @
06027381
...
...
@@ -12,9 +12,13 @@ KityMinder.registerModule( "TextEditModule", function () {
var
lastEvtPosition
,
dir
=
1
;
km
.
isTextEditStatus
=
function
(){
return
km
.
receiver
.
isTextEditStatus
();
}
};
return
{
//插入光标
...
...
@@ -25,12 +29,18 @@ KityMinder.registerModule( "TextEditModule", function () {
'beforemousedown'
:
function
(
e
){
sel
.
setHide
();
var
node
=
e
.
getTargetNode
();
if
(
!
node
){
var
selectionShape
=
e
.
kityEvent
.
targetShape
;
if
(
selectionShape
&&
selectionShape
.
getType
()
==
'Selection'
){
node
=
selectionShape
.
getData
(
'relatedNode'
);
}
}
if
(
node
){
var
textShape
=
node
.
getTextShape
();
textShape
.
setStyle
(
'cursor'
,
'default'
);
if
(
this
.
isSingleSelect
()
&&
node
.
isSelected
())
{
// && e.kityEvent.targetShape.getType().toLowerCase()== 'text'
sel
.
collapse
();
node
.
getTextShape
().
setStyle
(
'cursor'
,
'text'
);
receiver
.
setTextEditStatus
(
true
)
...
...
@@ -44,15 +54,20 @@ KityMinder.registerModule( "TextEditModule", function () {
.
setCurrentIndex
(
e
.
getPosition
())
.
updateSelection
()
.
setRange
(
range
);
sel
.
setData
(
'relatedNode'
,
node
);
mouseDownStatus
=
true
;
lastEvtPosition
=
e
.
getPosition
();
}
}
},
'mouseup'
:
function
(
e
){
if
(
!
sel
.
collapsed
&&
mouseDownStatus
){
receiver
.
updateRange
(
range
)
if
(
mouseDownStatus
){
if
(
!
sel
.
collapsed
){
receiver
.
updateRange
(
range
)
}
else
sel
.
setShow
()
}
mouseDownStatus
=
false
;
oneTime
=
0
;
},
...
...
@@ -62,7 +77,7 @@ KityMinder.registerModule( "TextEditModule", function () {
var
offset
=
e
.
getPosition
();
if
(
Math
.
abs
(
offset
.
y
-
lastEvtPosition
.
y
)
>
2
){
if
(
Math
.
abs
(
offset
.
y
-
lastEvtPosition
.
y
)
>
2
&&
Math
.
abs
(
lastEvtPosition
.
x
-
offset
.
x
)
<
1
){
sel
.
setHide
();
mouseDownStatus
=
false
;
return
;
...
...
@@ -70,7 +85,7 @@ KityMinder.registerModule( "TextEditModule", function () {
dir
=
offset
.
x
>
lastEvtPosition
.
x
?
1
:
(
offset
.
x
<
lastEvtPosition
.
x
?
-
1
:
dir
);
receiver
.
updateSelectionByMousePosition
(
offset
,
dir
)
.
updateSelectionShow
(
dir
);
sel
.
stroke
(
'none'
,
0
);
lastEvtPosition
=
e
.
getPosition
();
}
...
...
src/module/editor.selection.js
View file @
06027381
...
...
@@ -5,9 +5,9 @@ Minder.Selection = kity.createClass( 'Selection', {
this
.
callBase
();
this
.
height
=
height
||
20
;
this
.
stroke
(
color
||
'
blue
'
,
width
||
1
);
this
.
width
=
1
;
this
.
fill
(
'
#99C8FF
'
);
this
.
stroke
(
color
||
'
rgb(27,171,255)
'
,
width
||
1
);
this
.
width
=
0
;
this
.
fill
(
'
rgb(27,171,255)
'
);
this
.
setHide
();
this
.
timer
=
null
;
this
.
collapsed
=
true
;
...
...
@@ -17,7 +17,8 @@ Minder.Selection = kity.createClass( 'Selection', {
},
collapse
:
function
(
toEnd
){
this
.
stroke
(
'blue'
,
1
);
this
.
stroke
(
'rgb(27,171,255)'
,
1
);
this
.
setOpacity
(
1
);
this
.
width
=
1
;
this
.
collapsed
=
true
;
if
(
toEnd
){
...
...
@@ -38,7 +39,8 @@ Minder.Selection = kity.createClass( 'Selection', {
return
this
;
}
this
.
collapsed
=
false
;
this
.
stroke
(
'none'
);
this
.
stroke
(
'none'
,
0
);
this
.
setOpacity
(
0.5
);
return
this
;
},
setEndOffset
:
function
(
offset
){
...
...
@@ -52,10 +54,14 @@ Minder.Selection = kity.createClass( 'Selection', {
return
this
;
}
this
.
collapsed
=
false
;
this
.
stroke
(
'none'
);
this
.
stroke
(
'none'
,
0
);
this
.
setOpacity
(
0.5
);
return
this
;
},
updateShow
:
function
(
offset
,
width
){
if
(
width
){
this
.
setShowHold
();
}
this
.
setPosition
(
offset
).
setWidth
(
width
);
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