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
0bd6c8b4
Commit
0bd6c8b4
authored
Jul 06, 2014
by
techird
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dev' of github.com:fex-team/kityminder into dev
parents
053e37b4
d2b688c3
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
45 additions
and
21 deletions
+45
-21
editor.js
src/module/editor.js
+10
-1
editor.receiver.js
src/module/editor.receiver.js
+32
-20
editor.selection.js
src/module/editor.selection.js
+3
-0
No files found.
src/module/editor.js
View file @
0bd6c8b4
...
@@ -93,8 +93,11 @@ KityMinder.registerModule('TextEditModule', function() {
...
@@ -93,8 +93,11 @@ KityMinder.registerModule('TextEditModule', function() {
if
(
selectionReadyShow
){
if
(
selectionReadyShow
){
textShape
.
setStyle
(
'cursor'
,
'text'
);
textShape
.
setStyle
(
'cursor'
,
'text'
);
sel
.
clearBaseOffset
();
receiver
.
updateSelection
();
receiver
.
updateSelection
();
setTimeout
(
function
()
{
sel
.
setShow
();
},
200
);
km
.
setStatus
(
'textedit'
);
km
.
setStatus
(
'textedit'
);
}
}
...
@@ -143,9 +146,14 @@ KityMinder.registerModule('TextEditModule', function() {
...
@@ -143,9 +146,14 @@ KityMinder.registerModule('TextEditModule', function() {
sel
.
setColor
(
node
.
getStyle
(
'text-selection-color'
));
sel
.
setColor
(
node
.
getStyle
(
'text-selection-color'
));
sel
.
clearBaseOffset
();
node
.
getTextShape
().
setStyle
(
'cursor'
,
'text'
);
node
.
getTextShape
().
setStyle
(
'cursor'
,
'text'
);
receiver
.
updateSelection
();
receiver
.
updateSelection
();
setTimeout
(
function
()
{
sel
.
setShow
();
},
200
);
lastEvtPosition
=
e
.
getPosition
(
this
.
getRenderContainer
());
lastEvtPosition
=
e
.
getPosition
(
this
.
getRenderContainer
());
...
@@ -161,6 +169,7 @@ KityMinder.registerModule('TextEditModule', function() {
...
@@ -161,6 +169,7 @@ KityMinder.registerModule('TextEditModule', function() {
}
else
{
}
else
{
//当有光标时,要同步选区
//当有光标时,要同步选区
if
(
!
sel
.
collapsed
){
if
(
!
sel
.
collapsed
){
sel
.
clearBaseOffset
();
receiver
.
updateContainerRangeBySel
();
receiver
.
updateContainerRangeBySel
();
}
}
...
...
src/module/editor.receiver.js
View file @
0bd6c8b4
...
@@ -94,12 +94,13 @@ Minder.Receiver = kity.createClass('Receiver', {
...
@@ -94,12 +94,13 @@ Minder.Receiver = kity.createClass('Receiver', {
},
},
keyboardEvents
:
function
(
e
)
{
keyboardEvents
:
function
(
e
)
{
clearTimeout
(
this
.
timer
);
var
me
=
this
;
var
me
=
this
;
var
orgEvt
=
e
.
originEvent
;
var
orgEvt
=
e
.
originEvent
;
var
keyCode
=
orgEvt
.
keyCode
;
var
keyCode
=
orgEvt
.
keyCode
;
function
setTextToContainer
()
{
function
setTextToContainer
()
{
clearTimeout
(
me
.
timer
);
if
(
!
me
.
range
.
hasNativeRange
())
{
if
(
!
me
.
range
.
hasNativeRange
())
{
return
;
return
;
}
}
...
@@ -142,9 +143,10 @@ Minder.Receiver = kity.createClass('Receiver', {
...
@@ -142,9 +143,10 @@ Minder.Receiver = kity.createClass('Receiver', {
me
.
updateSelection
();
me
.
updateSelection
();
me
.
timer
=
setTimeout
(
function
()
{
me
.
timer
=
setTimeout
(
function
()
{
me
.
selection
.
setShow
();
me
.
selection
.
setShow
();
},
3
00
);
},
2
00
);
me
.
km
.
setStatus
(
'textedit'
);
me
.
km
.
setStatus
(
'textedit'
);
me
.
selection
.
clearBaseOffset
();
}
}
...
@@ -196,31 +198,40 @@ Minder.Receiver = kity.createClass('Receiver', {
...
@@ -196,31 +198,40 @@ Minder.Receiver = kity.createClass('Receiver', {
}
}
//针对按住shift+方向键进行处理
//针对按住shift+方向键进行处理
if
(
orgEvt
.
shiftKey
&&
keymap
.
direction
[
keyCode
]
&&
this
.
selection
.
isShow
()){
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
;
var
textlength
=
this
.
textShape
.
getContent
().
length
;
if
(
keymap
.
right
==
keyCode
){
if
(
keymap
.
right
==
keyCode
){
var
endOffset
=
this
.
selection
.
endOffset
+
1
;
this
.
selection
.
currentEndOffset
++
;
if
(
e
ndOffset
>
textlength
){
if
(
this
.
selection
.
currentE
ndOffset
>
textlength
){
e
ndOffset
=
textlength
;
this
.
selection
.
currentE
ndOffset
=
textlength
;
}
}
this
.
selection
.
setEndOffset
(
endOffset
);
}
else
if
(
keymap
.
left
==
keyCode
){
endOffset
=
this
.
selection
.
endOffset
-
1
;
}
else
if
(
keymap
.
left
==
keyCode
){
if
(
endOffset
<
0
){
this
.
selection
.
currentEndOffset
--
;
endOffset
=
0
;
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
{
}
else
if
(
keymap
.
up
==
keyCode
){
this
.
selection
.
setEndOffset
(
endOffset
);
this
.
selection
.
currentEndOffset
=
0
;
}
this
.
selection
.
baseOffset
=
this
.
selection
.
endOffset
;
}
else
{
this
.
selection
.
currentEndOffset
=
textlength
;
}
}
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
();
this
.
updateContainerRangeBySel
();
...
@@ -448,7 +459,8 @@ Minder.Receiver = kity.createClass('Receiver', {
...
@@ -448,7 +459,8 @@ Minder.Receiver = kity.createClass('Receiver', {
endOffset
=
this
.
textData
[
this
.
selection
.
endOffset
],
endOffset
=
this
.
textData
[
this
.
selection
.
endOffset
],
width
=
0
;
width
=
0
;
if
(
this
.
selection
.
collapsed
)
{
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
;
return
this
;
}
}
if
(
!
endOffset
)
{
if
(
!
endOffset
)
{
...
...
src/module/editor.selection.js
View file @
0bd6c8b4
...
@@ -116,5 +116,8 @@ Minder.Selection = kity.createClass( 'Selection', {
...
@@ -116,5 +116,8 @@ Minder.Selection = kity.createClass( 'Selection', {
},
},
isHide
:
function
(){
isHide
:
function
(){
return
!
this
.
_show
;
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