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
dd8bb74c
Commit
dd8bb74c
authored
Jun 26, 2014
by
campaign
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
模拟光标这个整体调整
parent
38a32e73
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
36 additions
and
37 deletions
+36
-37
minder.js
src/core/minder.js
+4
-0
dragtree.js
src/module/dragtree.js
+8
-0
editor.js
src/module/editor.js
+5
-12
editor.receiver.js
src/module/editor.receiver.js
+18
-10
editor.selection.js
src/module/editor.selection.js
+1
-15
No files found.
src/core/minder.js
View file @
dd8bb74c
...
@@ -176,6 +176,10 @@ var Minder = KityMinder.Minder = kity.createClass('KityMinder', {
...
@@ -176,6 +176,10 @@ var Minder = KityMinder.Minder = kity.createClass('KityMinder', {
},
},
setStatus
:
function
(
status
)
{
setStatus
:
function
(
status
)
{
if
(
status
)
{
if
(
status
)
{
this
.
fire
(
'statuschange'
,{
lastStatus
:
this
.
_status
,
currentStatus
:
status
});
this
.
_rollbackStatus
=
this
.
_status
;
this
.
_rollbackStatus
=
this
.
_status
;
this
.
_status
=
status
;
this
.
_status
=
status
;
}
else
{
}
else
{
...
...
src/module/dragtree.js
View file @
dd8bb74c
...
@@ -316,6 +316,9 @@ var TreeDragger = kity.createClass('TreeDragger', {
...
@@ -316,6 +316,9 @@ var TreeDragger = kity.createClass('TreeDragger', {
_renderOrderHint
:
function
(
hint
)
{
_renderOrderHint
:
function
(
hint
)
{
this
.
_orderHinter
.
render
(
hint
);
this
.
_orderHinter
.
render
(
hint
);
},
preventDragMove
:
function
(){
this
.
_startPosition
=
null
;
}
}
});
});
...
@@ -340,6 +343,11 @@ KityMinder.registerModule('DragTree', function() {
...
@@ -340,6 +343,11 @@ KityMinder.registerModule('DragTree', function() {
dragger
.
dragEnd
(
e
.
getPosition
(
this
.
getRenderContainer
()));
dragger
.
dragEnd
(
e
.
getPosition
(
this
.
getRenderContainer
()));
e
.
stopPropagation
();
e
.
stopPropagation
();
this
.
fire
(
'contentchange'
);
this
.
fire
(
'contentchange'
);
},
'statuschange'
:
function
(
e
){
if
(
e
.
lastStatus
==
'textedit'
&&
e
.
currentStatus
==
'normal'
){
dragger
.
preventDragMove
();
}
}
}
},
},
commands
:
{
commands
:
{
...
...
src/module/editor.js
View file @
dd8bb74c
...
@@ -40,7 +40,6 @@ KityMinder.registerModule('TextEditModule', function() {
...
@@ -40,7 +40,6 @@ KityMinder.registerModule('TextEditModule', function() {
'events'
:
{
'events'
:
{
'ready'
:
function
()
{
'ready'
:
function
()
{
this
.
_renderTarget
.
appendChild
(
receiver
.
container
);
this
.
_renderTarget
.
appendChild
(
receiver
.
container
);
this
.
getRenderContainer
().
addShape
(
sel
);
},
},
'normal.beforemousedown textedit.beforemousedown inputready.beforemousedown'
:
function
(
e
)
{
'normal.beforemousedown textedit.beforemousedown inputready.beforemousedown'
:
function
(
e
)
{
...
@@ -73,7 +72,6 @@ KityMinder.registerModule('TextEditModule', function() {
...
@@ -73,7 +72,6 @@ KityMinder.registerModule('TextEditModule', function() {
var
textShape
=
node
.
getTextShape
();
var
textShape
=
node
.
getTextShape
();
textShape
.
setStyle
(
'cursor'
,
'default'
);
textShape
.
setStyle
(
'cursor'
,
'default'
);
if
(
this
.
isSingleSelect
()
&&
node
.
isSelected
())
{
if
(
this
.
isSingleSelect
()
&&
node
.
isSelected
())
{
sel
.
collapse
();
sel
.
collapse
();
...
@@ -182,6 +180,8 @@ KityMinder.registerModule('TextEditModule', function() {
...
@@ -182,6 +180,8 @@ KityMinder.registerModule('TextEditModule', function() {
inputStatusReady
(
e
.
getTargetNode
());
inputStatusReady
(
e
.
getTargetNode
());
km
.
setStatus
(
'textedit'
);
receiver
.
updateSelectionShow
();
receiver
.
updateSelectionShow
();
},
},
// 'restoreScene': function() {
// 'restoreScene': function() {
...
@@ -226,7 +226,7 @@ KityMinder.registerModule('TextEditModule', function() {
...
@@ -226,7 +226,7 @@ KityMinder.registerModule('TextEditModule', function() {
};
};
if
(
cmds
[
e
.
commandName
])
{
if
(
cmds
[
e
.
commandName
])
{
inputStatusReady
(
km
.
getSelectedNode
());
inputStatusReady
(
km
.
getSelectedNode
());
selectionReadyShow
=
true
;
receiver
.
updateSelectionShow
()
;
return
;
return
;
}
}
...
@@ -236,18 +236,11 @@ KityMinder.registerModule('TextEditModule', function() {
...
@@ -236,18 +236,11 @@ KityMinder.registerModule('TextEditModule', function() {
this
.
setStatus
(
'normal'
);
this
.
setStatus
(
'normal'
);
}
}
},
},
'layout
apply
'
:
function
(
e
){
'layout
finish
'
:
function
(
e
){
if
(
e
.
node
===
receiver
.
minderNode
&&
(
this
.
getStatus
()
==
'textedit'
||
this
.
getStatus
()
==
'inputready'
)
)
{
//&& selectionReadyShow
if
(
e
.
node
===
receiver
.
minderNode
&&
(
this
.
getStatus
()
==
'textedit'
||
this
.
getStatus
()
==
'inputready'
)
)
{
//&& selectionReadyShow
receiver
receiver
.
setBaseOffset
()
.
setBaseOffset
()
.
setContainerStyle
()
.
setContainerStyle
();
.
updateTextOffsetData
();
if
(
sel
.
collapsed
)
{
receiver
.
updateSelection
();
}
else
{
receiver
.
updateSelectionShow
();
}
}
}
},
},
...
...
src/module/editor.receiver.js
View file @
dd8bb74c
...
@@ -61,16 +61,14 @@ Minder.Receiver = kity.createClass('Receiver', {
...
@@ -61,16 +61,14 @@ Minder.Receiver = kity.createClass('Receiver', {
getTextShapeHeight
:
function
()
{
getTextShapeHeight
:
function
()
{
return
this
.
textShape
.
getRenderBox
().
height
;
return
this
.
textShape
.
getRenderBox
().
height
;
},
},
appendTextShapeToPaper
:
function
(
paper
)
{
paper
.
addShape
(
this
.
textShape
);
return
this
;
},
setKityMinder
:
function
(
km
)
{
setKityMinder
:
function
(
km
)
{
this
.
km
=
km
;
this
.
km
=
km
;
return
this
;
return
this
;
},
},
setMinderNode
:
function
(
node
)
{
setMinderNode
:
function
(
node
)
{
this
.
minderNode
=
node
;
this
.
minderNode
=
node
;
//追加selection到节点
this
.
_addSelection
();
//更新minderNode下的textshape
//更新minderNode下的textshape
this
.
setTextShape
(
node
.
getTextShape
());
this
.
setTextShape
(
node
.
getTextShape
());
//更新textshape的baseOffset
//更新textshape的baseOffset
...
@@ -86,6 +84,10 @@ Minder.Receiver = kity.createClass('Receiver', {
...
@@ -86,6 +84,10 @@ Minder.Receiver = kity.createClass('Receiver', {
return
this
;
return
this
;
},
},
_addSelection
:
function
(){
if
(
this
.
selection
.
container
)
this
.
selection
.
remove
();
this
.
minderNode
.
getRenderContainer
().
addShape
(
this
.
selection
);
},
getMinderNode
:
function
(){
getMinderNode
:
function
(){
return
this
.
minderNode
;
return
this
.
minderNode
;
},
},
...
@@ -119,7 +121,7 @@ Minder.Receiver = kity.createClass('Receiver', {
...
@@ -119,7 +121,7 @@ Minder.Receiver = kity.createClass('Receiver', {
me
.
minderNode
.
render
();
me
.
minderNode
.
render
();
clearTimeout
(
me
.
inputTextTimer
);
clearTimeout
(
me
.
inputTextTimer
);
me
.
inputTextTimer
=
setTimeout
(
function
(){
me
.
inputTextTimer
=
setTimeout
(
function
(){
me
.
km
.
layout
();
me
.
km
.
layout
(
300
);
},
250
);
},
250
);
me
.
textShape
=
me
.
minderNode
.
getRenderer
(
'TextRenderer'
).
getRenderShape
();
me
.
textShape
=
me
.
minderNode
.
getRenderer
(
'TextRenderer'
).
getRenderShape
();
...
@@ -314,8 +316,8 @@ Minder.Receiver = kity.createClass('Receiver', {
...
@@ -314,8 +316,8 @@ Minder.Receiver = kity.createClass('Receiver', {
}
}
this
.
textData
.
push
({
this
.
textData
.
push
({
x
:
box
.
x
+
this
.
offset
.
x
,
x
:
box
.
x
,
y
:
this
.
offset
.
y
,
y
:
box
.
y
,
width
:
box
.
width
,
width
:
box
.
width
,
height
:
box
.
height
height
:
box
.
height
});
});
...
@@ -326,6 +328,8 @@ Minder.Receiver = kity.createClass('Receiver', {
...
@@ -326,6 +328,8 @@ Minder.Receiver = kity.createClass('Receiver', {
var
me
=
this
;
var
me
=
this
;
this
.
getTextOffsetData
();
this
.
getTextOffsetData
();
var
hadChanged
=
false
;
var
hadChanged
=
false
;
//要剪掉基数
this
.
_getRelativeValue
(
offset
);
utils
.
each
(
this
.
textData
,
function
(
i
,
v
)
{
utils
.
each
(
this
.
textData
,
function
(
i
,
v
)
{
//点击开始之前
//点击开始之前
if
(
i
===
0
&&
offset
.
x
<=
v
.
x
)
{
if
(
i
===
0
&&
offset
.
x
<=
v
.
x
)
{
...
@@ -356,9 +360,13 @@ Minder.Receiver = kity.createClass('Receiver', {
...
@@ -356,9 +360,13 @@ Minder.Receiver = kity.createClass('Receiver', {
this
.
selection
.
setHeight
(
this
.
getTextShapeHeight
());
this
.
selection
.
setHeight
(
this
.
getTextShapeHeight
());
return
this
;
return
this
;
},
},
_getRelativeValue
:
function
(
offset
){
offset
.
x
=
offset
.
x
-
this
.
offset
.
x
;
offset
.
y
=
offset
.
y
-
this
.
offset
.
y
;
},
updateSelectionByMousePosition
:
function
(
offset
,
dir
)
{
updateSelectionByMousePosition
:
function
(
offset
,
dir
)
{
//要剪掉基数
this
.
_getRelativeValue
(
offset
);
var
me
=
this
;
var
me
=
this
;
utils
.
each
(
this
.
textData
,
function
(
i
,
v
)
{
utils
.
each
(
this
.
textData
,
function
(
i
,
v
)
{
//点击开始之前
//点击开始之前
...
@@ -435,7 +443,7 @@ Minder.Receiver = kity.createClass('Receiver', {
...
@@ -435,7 +443,7 @@ Minder.Receiver = kity.createClass('Receiver', {
return
this
;
return
this
;
},
},
updateContainerRangeBySel
:
function
(){
updateContainerRangeBySel
:
function
(){
this
.
updateRange
(
this
.
range
)
this
.
updateRange
(
this
.
range
)
;
},
},
setIndex
:
function
(
index
)
{
setIndex
:
function
(
index
)
{
this
.
index
=
index
;
this
.
index
=
index
;
...
...
src/module/editor.selection.js
View file @
dd8bb74c
...
@@ -15,7 +15,7 @@ Minder.Selection = kity.createClass( 'Selection', {
...
@@ -15,7 +15,7 @@ Minder.Selection = kity.createClass( 'Selection', {
this
.
setOpacity
(
0.5
);
this
.
setOpacity
(
0.5
);
this
.
setStyle
(
'cursor'
,
'text'
);
this
.
setStyle
(
'cursor'
,
'text'
);
this
.
_show
=
false
;
this
.
_show
=
false
;
this
.
selectionShowStatus
=
true
;
},
},
collapse
:
function
(
toEnd
){
collapse
:
function
(
toEnd
){
...
@@ -121,19 +121,5 @@ Minder.Selection = kity.createClass( 'Selection', {
...
@@ -121,19 +121,5 @@ Minder.Selection = kity.createClass( 'Selection', {
},
},
isHide
:
function
(){
isHide
:
function
(){
return
!
this
.
_show
;
return
!
this
.
_show
;
},
setTextShape
:
function
(
text
)
{
if
(
!
text
)
{
this
.
text
=
new
kity
.
Text
();
}
else
{
this
.
text
=
text
;
}
return
this
;
},
getTextShape
:
function
()
{
return
this
.
text
;
},
setTxtContent
:
function
(
text
)
{
this
.
text
.
setContent
(
text
);
}
}
}
);
}
);
\ 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