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
49821b86
Commit
49821b86
authored
Jul 04, 2014
by
techird
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dev' of github.com:fex-team/kityminder into dev
parents
7fd89174
ee0677b8
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
72 additions
and
43 deletions
+72
-43
keymap.js
src/core/keymap.js
+7
-0
editor.js
src/module/editor.js
+13
-6
editor.receiver.js
src/module/editor.receiver.js
+46
-21
editor.selection.js
src/module/editor.selection.js
+5
-16
paste.js
src/module/paste.js
+1
-0
No files found.
src/core/keymap.js
View file @
49821b86
...
...
@@ -26,11 +26,18 @@ var keymap = KityMinder.keymap = (function(origin) {
'End'
:
35
,
'Home'
:
36
,
'Left'
:
37
,
'Up'
:
38
,
'Right'
:
39
,
'Down'
:
40
,
'direction'
:{
37
:
1
,
38
:
1
,
39
:
1
,
40
:
1
},
'Insert'
:
45
,
'Del'
:
46
,
...
...
src/module/editor.js
View file @
49821b86
...
...
@@ -48,7 +48,7 @@ KityMinder.registerModule('TextEditModule', function() {
return
{
'events'
:
{
'ready'
:
function
()
{
this
.
_renderTarget
.
appendChild
(
receiver
.
container
);
document
.
body
.
appendChild
(
receiver
.
container
);
},
'normal.beforemousedown textedit.beforemousedown inputready.beforemousedown'
:
function
(
e
)
{
...
...
@@ -83,7 +83,6 @@ KityMinder.registerModule('TextEditModule', function() {
if
(
this
.
isSingleSelect
()
&&
node
.
isSelected
())
{
sel
.
collapse
();
sel
.
setColor
(
node
.
getStyle
(
'text-selection-color'
));
receiver
.
setMinderNode
(
node
)
.
setCurrentIndex
(
e
.
getPosition
(
this
.
getRenderContainer
()))
...
...
@@ -133,13 +132,13 @@ KityMinder.registerModule('TextEditModule', function() {
}
},
'normal.mouseup textedit.mouseup inputready.mouseup'
:
function
(
e
)
{
mouseDownStatus
=
false
;
var
node
=
e
.
getTargetNode
();
if
(
node
&&
!
selectionReadyShow
&&
receiver
.
isReady
())
{
sel
.
collapse
();
sel
.
setColor
(
node
.
getStyle
(
'text-selection-color'
));
...
...
@@ -159,9 +158,17 @@ KityMinder.registerModule('TextEditModule', function() {
//当选中节点后,输入状态准备
if
(
sel
.
isHide
()){
inputStatusReady
(
e
.
getTargetNode
());
}
else
{
//当有光标时,要同步选区
if
(
!
sel
.
collapsed
){
receiver
.
updateContainerRangeBySel
();
}
}
},
'textedit.beforemousemove inputready.beforemousemove'
:
function
(
e
)
{
...
...
@@ -240,9 +247,9 @@ KityMinder.registerModule('TextEditModule', function() {
km
.
setStatus
(
'normal'
);
receiver
.
clear
();
},
//
'blur': function() {
//
receiver.clear();
//
},
'blur'
:
function
()
{
receiver
.
clear
();
},
'import'
:
function
()
{
km
.
setStatus
(
'normal'
);
receiver
.
clear
();
...
...
src/module/editor.receiver.js
View file @
49821b86
...
...
@@ -40,6 +40,7 @@ Minder.Receiver = kity.createClass('Receiver', {
this
.
range
=
range
;
range
.
setStart
(
text
||
this
.
container
,
this
.
index
).
collapse
(
true
);
var
me
=
this
;
setTimeout
(
function
()
{
me
.
container
.
focus
();
range
.
select
();
...
...
@@ -162,10 +163,6 @@ Minder.Receiver = kity.createClass('Receiver', {
switch
(
keyCode
)
{
case
keymap
.
Enter
:
case
keymap
.
Tab
:
case
keymap
.
left
:
case
keymap
.
right
:
case
keymap
.
up
:
case
keymap
.
down
:
if
(
this
.
selection
.
isShow
()){
this
.
clear
();
this
.
km
.
setStatus
(
'inputready'
);
...
...
@@ -176,7 +173,16 @@ Minder.Receiver = kity.createClass('Receiver', {
this
.
km
.
fire
(
'contentchange'
);
}
return
;
case
keymap
.
Shift
:
case
keymap
.
left
:
case
keymap
.
right
:
case
keymap
.
up
:
case
keymap
.
down
:
if
(
this
.
selection
.
isHide
()){
this
.
km
.
setStatus
(
'normal'
);
return
;
}
break
;
// case keymap.Shift:
case
keymap
.
Control
:
case
keymap
.
Alt
:
case
keymap
.
Cmd
:
...
...
@@ -188,7 +194,40 @@ Minder.Receiver = kity.createClass('Receiver', {
}
return
;
}
//针对按住shift+方向键进行处理
if
(
orgEvt
.
shiftKey
&&
keymap
.
direction
[
keyCode
]
&&
this
.
selection
.
isShow
()){
var
textlength
=
this
.
textShape
.
getContent
().
length
;
if
(
keymap
.
right
==
keyCode
){
var
endOffset
=
this
.
selection
.
endOffset
+
1
;
if
(
endOffset
>
textlength
){
endOffset
=
textlength
;
}
this
.
selection
.
setEndOffset
(
endOffset
);
}
else
if
(
keymap
.
left
==
keyCode
){
endOffset
=
this
.
selection
.
endOffset
-
1
;
if
(
endOffset
<
0
){
endOffset
=
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
);
}
}
this
.
updateContainerRangeBySel
();
this
.
updateSelectionShow
();
e
.
preventDefault
();
return
;
}
if
(
e
.
originEvent
.
ctrlKey
||
e
.
originEvent
.
metaKey
)
{
//粘贴
...
...
@@ -289,25 +328,11 @@ Minder.Receiver = kity.createClass('Receiver', {
return
this
;
},
setContainerStyle
:
function
()
{
var
textShapeBox
=
this
.
getBaseOffset
(
'
paper
'
);
var
textShapeBox
=
this
.
getBaseOffset
(
'
screen
'
);
this
.
container
.
style
.
cssText
=
';left:'
+
(
browser
.
ipad
?
'-'
:
''
)
+
textShapeBox
.
x
+
'px;top:'
+
(
textShapeBox
.
y
+
textShapeBox
.
height
*
0.1
)
+
textShapeBox
.
x
+
'px;top:'
+
(
textShapeBox
.
y
)
+
'px;width:'
+
textShapeBox
.
width
+
'px;height:'
+
textShapeBox
.
height
+
'px;'
;
if
(
!
this
.
selection
.
isShow
())
{
var
paperContainer
=
this
.
km
.
getPaper
();
var
width
=
paperContainer
.
node
.
parentNode
.
clientWidth
;
var
height
=
paperContainer
.
node
.
parentNode
.
clientHeight
;
if
(
width
<
this
.
container
.
offsetWidth
+
this
.
container
.
offsetLeft
)
{
this
.
km
.
getRenderContainer
().
translate
(
width
/
-
3
,
0
);
this
.
setContainerStyle
();
}
else
if
(
height
<
this
.
container
.
offsetTop
+
this
.
container
.
offsetHeight
)
{
this
.
km
.
getRenderContainer
().
translate
(
0
,
height
/
-
3
);
this
.
setContainerStyle
();
}
}
return
this
;
},
getTextOffsetData
:
function
()
{
...
...
src/module/editor.selection.js
View file @
49821b86
...
...
@@ -5,8 +5,7 @@ Minder.Selection = kity.createClass( 'Selection', {
this
.
callBase
();
this
.
height
=
height
||
20
;
this
.
setAttr
(
'id'
,
'_kity_selection'
);
this
.
stroke
(
color
||
'rgb(27,171,255)'
,
width
||
1
);
this
.
width
=
0
;
this
.
width
=
2
;
this
.
fill
(
'rgb(27,171,255)'
);
this
.
setHide
();
this
.
timer
=
null
;
...
...
@@ -18,14 +17,11 @@ Minder.Selection = kity.createClass( 'Selection', {
},
setColor
:
function
(
color
){
this
.
stroke
(
color
);
this
.
fill
(
color
);
},
collapse
:
function
(
toEnd
){
// this.stroke( 'rgb(27,171,255)', 1 );
this
.
setOpacity
(
1
);
this
.
width
=
1
;
this
.
width
=
2
;
this
.
collapsed
=
true
;
if
(
toEnd
){
this
.
startOffset
=
this
.
endOffset
;
...
...
@@ -45,7 +41,6 @@ Minder.Selection = kity.createClass( 'Selection', {
return
this
;
}
this
.
collapsed
=
false
;
this
.
stroke
(
'none'
,
0
);
this
.
setOpacity
(
0.5
);
return
this
;
},
...
...
@@ -60,7 +55,7 @@ Minder.Selection = kity.createClass( 'Selection', {
return
this
;
}
this
.
collapsed
=
false
;
this
.
stroke
(
'none'
,
0
);
//
this.stroke('none',0);
this
.
setOpacity
(
0.5
);
return
this
;
},
...
...
@@ -69,19 +64,13 @@ Minder.Selection = kity.createClass( 'Selection', {
this
.
setShowHold
();
}
this
.
setPosition
(
offset
).
setWidth
(
width
);
//解决在框选内容时,出现很窄的光标
if
(
width
===
0
){
this
.
setOpacity
(
0
);
}
else
{
this
.
setOpacity
(
0.5
);
}
this
.
bringTop
();
return
this
;
},
setPosition
:
function
(
offset
)
{
try
{
this
.
x
=
offset
.
x
;
this
.
y
=
offset
.
y
;
this
.
x
=
Math
.
round
(
offset
.
x
)
;
this
.
y
=
Math
.
round
(
offset
.
y
)
;
}
catch
(
e
)
{
console
.
log
(
e
);
...
...
src/module/paste.js
View file @
49821b86
...
...
@@ -45,6 +45,7 @@ KityMinder.registerModule( "pasteModule", function () {
break
;
case
keys
.
x
:
getNodes
(
km
.
getSelectedAncestors
(),
true
);
km
.
layout
(
300
);
_curstatus
=
true
;
break
;
case
keys
.
v
:
...
...
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