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
1147ff8b
Commit
1147ff8b
authored
Feb 16, 2014
by
campaign
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
by zhanyi
parent
7c060bf0
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
43 additions
and
44 deletions
+43
-44
editor.js
src/module/editor.js
+17
-9
editor.receiver.js
src/module/editor.receiver.js
+22
-31
editor.selection.js
src/module/editor.selection.js
+4
-4
No files found.
src/module/editor.js
View file @
1147ff8b
...
...
@@ -42,19 +42,27 @@ KityMinder.registerModule( "TextEditModule", function () {
}
},
'mouseup'
:
function
(
e
){
if
(
!
sel
.
collapsed
){
receiver
.
updateRange
(
range
)
}
mouseDownStatus
=
false
;
oneTime
=
0
;
},
'mousemove'
:
function
(
e
){
if
(
mouseDownStatus
){
var
offset
=
e
.
getPosition
();
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
();
}
setTimeout
(
function
(){
if
(
mouseDownStatus
){
var
offset
=
e
.
getPosition
();
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
();
}
},
100
)
},
'restoreScene'
:
function
(){
sel
.
setHide
();
...
...
src/module/editor.receiver.js
View file @
1147ff8b
...
...
@@ -205,55 +205,42 @@ Minder.Receiver = kity.createClass('Receiver',{
this
.
selection
.
setHeight
(
this
.
getTextShapeHeight
());
return
this
;
},
getIndexByMousePosition
:
function
(
offset
,
dir
){
updateSelectionByMousePosition
:
function
(
offset
,
dir
){
var
me
=
this
;
var
currentIndex
;
var
hadChanged
=
false
;
utils
.
each
(
this
.
textData
,
function
(
i
,
v
){
//点击开始之前
if
(
i
==
0
&&
offset
.
x
<=
v
.
x
){
currentIndex
=
0
;
me
.
selection
.
setStartOffset
(
0
)
;
return
false
;
}
if
(
i
==
me
.
textData
.
length
-
1
&&
offset
.
x
>=
v
.
x
){
currentIndex
=
me
.
textData
.
length
;
me
.
selection
.
setEndOffset
(
me
.
textData
.
length
)
;
return
false
;
}
if
(
offset
.
x
>=
v
.
x
&&
offset
.
x
<=
v
.
x
+
v
.
width
){
currentIndex
=
i
+
(
dir
==
-
1
?
0
:
1
);
return
false
;
}
});
return
currentIndex
;
},
updateSelectionByMousePosition
:
function
(
offset
,
dir
){
var
currentIndex
=
this
.
getIndexByMousePosition
(
offset
,
dir
);
if
(
me
.
index
==
i
){
me
.
selection
.
setEndOffset
(
i
+
(
dir
==
1
?
1
:
0
))
}
else
if
(
i
>
me
.
index
){
me
.
selection
.
setEndOffset
(
i
+
(
dir
==
1
?
1
:
0
))
}
else
{
me
.
selection
.
setStartOffset
(
i
+
(
dir
==
1
?
1
:
0
))
}
if
(
currentIndex
==
0
){
this
.
selection
.
setStartOffset
(
0
)
}
else
if
(
currentIndex
==
this
.
textData
.
length
){
this
.
selection
.
setEndOffset
(
currentIndex
)
}
else
{
if
(
currentIndex
>
this
.
index
){
this
.
selection
.
setEndOffset
(
currentIndex
)
}
else
if
(
currentIndex
<
this
.
index
){
this
.
selection
.
setStartOffset
(
currentIndex
)
}
else
{
this
.
selection
.
collapse
()
return
false
;
}
}
});
return
this
;
},
updateSelectionShow
:
function
(
dir
){
updateSelectionShow
:
function
(){
var
startOffset
=
this
.
textData
[
this
.
selection
.
startOffset
],
endOffset
=
this
.
textData
[
this
.
selection
.
endOffset
],
width
=
0
;
if
(
this
.
selection
.
isC
ollapsed
){
if
(
this
.
selection
.
c
ollapsed
){
this
.
selection
.
updateShow
(
startOffset
,
0
);
return
this
;
...
...
@@ -268,7 +255,11 @@ Minder.Receiver = kity.createClass('Receiver',{
this
.
selection
.
updateShow
(
startOffset
,
width
);
return
this
;
},
updateNativeRange
:
function
(){
updateRange
:
function
(
range
){
var
node
=
this
.
container
.
firstChild
;
range
.
setStart
(
node
,
this
.
selection
.
startOffset
);
range
.
setEnd
(
node
,
this
.
selection
.
endOffset
);
range
.
select
();
return
this
;
}
});
\ No newline at end of file
src/module/editor.selection.js
View file @
1147ff8b
...
...
@@ -10,7 +10,7 @@ Minder.Selection = kity.createClass( 'Selection', {
this
.
fill
(
'#99C8FF'
);
this
.
setHide
();
this
.
timer
=
null
;
this
.
isC
ollapsed
=
true
;
this
.
c
ollapsed
=
true
;
this
.
startOffset
=
this
.
endOffset
=
0
;
this
.
setOpacity
(
0.5
)
},
...
...
@@ -18,7 +18,7 @@ Minder.Selection = kity.createClass( 'Selection', {
this
.
stroke
(
'blue'
,
1
);
this
.
width
=
1
;
this
.
isC
ollapsed
=
true
;
this
.
c
ollapsed
=
true
;
if
(
toEnd
){
this
.
startOffset
=
this
.
endOffset
}
else
{
...
...
@@ -36,7 +36,7 @@ Minder.Selection = kity.createClass( 'Selection', {
this
.
collapse
();
return
this
;
}
this
.
isC
ollapsed
=
false
;
this
.
c
ollapsed
=
false
;
this
.
stroke
(
'none'
);
return
this
;
},
...
...
@@ -50,7 +50,7 @@ Minder.Selection = kity.createClass( 'Selection', {
this
.
collapse
();
return
this
;
}
this
.
isC
ollapsed
=
false
;
this
.
c
ollapsed
=
false
;
this
.
stroke
(
'none'
);
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