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
02f04f4c
Commit
02f04f4c
authored
Jun 25, 2014
by
campaign
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
模拟光标这个整体调整
parent
82e40daf
Changes
11
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
223 additions
and
324 deletions
+223
-324
connect.js
src/core/connect.js
+1
-1
minder.js
src/core/minder.js
+0
-3
minder.node.js
src/core/minder.node.js
+9
-2
dragtree.js
src/module/dragtree.js
+3
-3
editor.js
src/module/editor.js
+136
-288
editor.receiver.js
src/module/editor.receiver.js
+53
-19
editor.selection.js
src/module/editor.selection.js
+6
-2
history.js
src/module/history.js
+4
-1
node.js
src/module/node.js
+1
-1
select.js
src/module/select.js
+5
-4
text.js
src/module/text.js
+5
-0
No files found.
src/core/connect.js
View file @
02f04f4c
...
...
@@ -69,7 +69,7 @@ kity.extendClass(Minder, {
KityMinder
.
registerModule
(
'Connect'
,
{
events
:
{
'node
create
'
:
function
(
e
)
{
'node
attach
'
:
function
(
e
)
{
this
.
createConnect
(
e
.
node
);
},
'noderemove'
:
function
(
e
)
{
...
...
src/core/minder.js
View file @
02f04f4c
...
...
@@ -88,9 +88,6 @@ var Minder = KityMinder.Minder = kity.createClass('KityMinder', {
this
.
_shortcutkeys
=
{};
this
.
_bindshortcutKeys
();
},
isTextEditStatus
:
function
()
{
return
false
;
},
addShortcutKeys
:
function
(
cmd
,
keys
)
{
var
obj
=
{},
km
=
this
;
...
...
src/core/minder.node.js
View file @
02f04f4c
...
...
@@ -11,13 +11,20 @@ kity.extendClass(Minder, {
createNode
:
function
(
unknown
,
parent
,
index
)
{
var
node
=
new
MinderNode
(
unknown
);
this
.
fire
(
'nodecreate'
,
{
node
:
node
});
this
.
appendNode
(
node
,
parent
,
index
);
return
node
;
},
appendNode
:
function
(
node
,
parent
,
index
)
{
if
(
parent
)
parent
.
insertChild
(
node
,
index
);
this
.
handelNodeCreate
(
node
);
this
.
fire
(
'node
create
'
,
{
this
.
fire
(
'node
attach
'
,
{
node
:
node
});
return
node
;
return
this
;
},
removeNode
:
function
(
node
)
{
...
...
src/module/dragtree.js
View file @
02f04f4c
...
...
@@ -327,16 +327,16 @@ KityMinder.registerModule('DragTree', function() {
dragger
=
new
TreeDragger
(
this
);
},
events
:
{
'mousedown'
:
function
(
e
)
{
'
normal.mousedown inputready.
mousedown'
:
function
(
e
)
{
// 单选中根节点也不触发拖拽
if
(
e
.
getTargetNode
()
&&
e
.
getTargetNode
()
!=
this
.
getRoot
())
{
dragger
.
dragStart
(
e
.
getPosition
(
this
.
getRenderContainer
()));
}
},
'mousemove'
:
function
(
e
)
{
'
normal.
mousemove'
:
function
(
e
)
{
dragger
.
dragMove
(
e
.
getPosition
(
this
.
getRenderContainer
()));
},
'mouseup'
:
function
(
e
)
{
'
normal.
mouseup'
:
function
(
e
)
{
dragger
.
dragEnd
(
e
.
getPosition
(
this
.
getRenderContainer
()));
e
.
stopPropagation
();
this
.
fire
(
'contentchange'
);
...
...
src/module/editor.js
View file @
02f04f4c
This diff is collapsed.
Click to expand it.
src/module/editor.receiver.js
View file @
02f04f4c
...
...
@@ -12,17 +12,10 @@ Minder.Receiver = kity.createClass('Receiver', {
this
.
isTypeText
=
false
;
return
this
;
},
setTextEditStatus
:
function
(
status
)
{
this
.
textEditStatus
=
status
||
false
;
return
this
;
},
isTextEditStatus
:
function
()
{
return
this
.
textEditStatus
;
},
constructor
:
function
(
km
)
{
constructor
:
function
(
km
,
sel
,
range
)
{
var
me
=
this
;
this
.
setKityMinder
(
km
);
this
.
textEditStatus
=
false
;
var
_div
=
document
.
createElement
(
'div'
);
_div
.
setAttribute
(
'contenteditable'
,
true
);
_div
.
className
=
'km_receiver'
;
...
...
@@ -33,9 +26,11 @@ Minder.Receiver = kity.createClass('Receiver', {
});
}
utils
.
addCssRule
(
'km_receiver_css'
,
' .km_receiver{white-space:nowrap;position:absolute;padding:0;margin:0;word-wrap:break-word;clip:rect(1em 1em 1em 1em);'
);
//
this
.
km
.
on
(
'textedit.beforekeyup textedit.beforekeydown textedit.keypress textedit.paste'
,
utils
.
proxy
(
this
.
keyboardEvents
,
this
));
this
.
km
.
on
(
'
inputready.beforekeyup inputready.beforekeydown
textedit.beforekeyup textedit.beforekeydown textedit.keypress textedit.paste'
,
utils
.
proxy
(
this
.
keyboardEvents
,
this
));
this
.
timer
=
null
;
this
.
index
=
0
;
this
.
selection
=
sel
;
this
.
range
=
range
;
},
setRange
:
function
(
range
,
index
)
{
...
...
@@ -76,15 +71,30 @@ Minder.Receiver = kity.createClass('Receiver', {
},
setMinderNode
:
function
(
node
)
{
this
.
minderNode
=
node
;
//更新minderNode下的textshape
this
.
setTextShape
(
node
.
getTextShape
());
//更新textshape的baseOffset
this
.
setBaseOffset
();
//更新接受容器的样式
this
.
setContainerStyle
();
//更新textOffsetData数据
this
.
updateTextOffsetData
();
//更新选取高度
this
.
setSelectionHeight
();
//更新接收容器内容
this
.
setContainerTxt
();
return
this
;
},
getMinderNode
:
function
(){
return
this
.
minderNode
;
},
keyboardEvents
:
function
(
e
)
{
clearTimeout
(
this
.
timer
);
var
me
=
this
;
var
orgEvt
=
e
.
originEvent
;
var
keyCode
=
orgEvt
.
keyCode
;
var
keys
=
KityMinder
.
keymap
;
function
setTextToContainer
()
{
if
(
!
me
.
range
.
hasNativeRange
())
{
...
...
@@ -109,7 +119,7 @@ Minder.Receiver = kity.createClass('Receiver', {
me
.
minderNode
.
render
();
clearTimeout
(
me
.
inputTextTimer
);
me
.
inputTextTimer
=
setTimeout
(
function
(){
me
.
km
.
layout
(
300
);
me
.
km
.
layout
();
},
250
);
me
.
textShape
=
me
.
minderNode
.
getRenderer
(
'TextRenderer'
).
getRenderShape
();
...
...
@@ -117,15 +127,14 @@ Minder.Receiver = kity.createClass('Receiver', {
me
.
textShape
.
setOpacity
(
0
);
}
me
.
setBaseOffset
();
me
.
updateTextData
();
me
.
updateTextOffsetData
();
me
.
updateIndex
();
me
.
updateSelection
();
me
.
timer
=
setTimeout
(
function
()
{
me
.
selection
.
setShow
();
},
300
);
me
.
km
.
setStatus
(
'textedit'
);
}
...
...
@@ -144,8 +153,14 @@ 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
().
setTextEditStatus
(
false
);
this
.
clear
();
this
.
km
.
setStatus
(
'inputready'
);
clearTimeout
(
me
.
inputTextTimer
);
e
.
preventDefault
();
}
else
{
this
.
km
.
setStatus
(
'normal'
);
...
...
@@ -157,6 +172,12 @@ Minder.Receiver = kity.createClass('Receiver', {
case
keymap
.
Alt
:
case
keymap
.
Cmd
:
return
;
case
keymap
.
Del
:
case
keymap
.
Backspace
:
if
(
!
this
.
selection
.
isShow
()){
this
.
km
.
setStatus
(
'normal'
);
return
;
}
}
if
(
e
.
originEvent
.
ctrlKey
||
e
.
originEvent
.
metaKey
)
{
...
...
@@ -197,7 +218,6 @@ Minder.Receiver = kity.createClass('Receiver', {
}
if
(
this
.
keydownNode
===
this
.
minderNode
)
{
this
.
rollbackStatus
();
this
.
setTextEditStatus
(
false
);
this
.
clear
();
}
e
.
preventDefault
();
...
...
@@ -205,6 +225,7 @@ Minder.Receiver = kity.createClass('Receiver', {
case
keymap
.
Del
:
case
keymap
.
Backspace
:
case
keymap
.
Spacebar
:
setTextToContainer
();
return
;
}
...
...
@@ -222,7 +243,7 @@ Minder.Receiver = kity.createClass('Receiver', {
this
.
index
=
this
.
range
.
getStart
().
startOffset
;
return
this
;
},
updateTextData
:
function
()
{
updateText
Offset
Data
:
function
()
{
this
.
textShape
.
textData
=
this
.
getTextOffsetData
();
return
this
;
},
...
...
@@ -406,18 +427,31 @@ Minder.Receiver = kity.createClass('Receiver', {
return
this
;
},
updateRange
:
function
(
range
)
{
range
=
range
||
this
.
range
;
var
node
=
this
.
container
.
firstChild
;
range
.
setStart
(
node
,
this
.
selection
.
startOffset
);
range
.
setEnd
(
node
,
this
.
selection
.
endOffset
);
range
.
select
();
return
this
;
},
updateContainerRangeBySel
:
function
(){
this
.
updateRange
(
this
.
range
)
},
setIndex
:
function
(
index
)
{
this
.
index
=
index
;
return
this
;
},
setContainerTxt
:
function
(
txt
)
{
this
.
container
.
textContent
=
txt
;
this
.
container
.
textContent
=
txt
||
this
.
textShape
.
getContent
()
;
return
this
;
},
setReady
:
function
(){
this
.
_ready
=
true
;
},
clearReady
:
function
(){
this
.
_ready
=
false
;
},
isReady
:
function
(){
return
this
.
_ready
;
}
});
\ No newline at end of file
src/module/editor.selection.js
View file @
02f04f4c
...
...
@@ -82,10 +82,12 @@ Minder.Selection = kity.createClass( 'Selection', {
}
catch
(
e
)
{
console
.
log
(
e
);
}
return
this
.
update
();
this
.
update
();
return
this
;
},
setHeight
:
function
(
height
)
{
this
.
height
=
height
;
return
this
;
},
setHide
:
function
()
{
clearInterval
(
this
.
timer
);
...
...
@@ -112,12 +114,14 @@ Minder.Selection = kity.createClass( 'Selection', {
state
=
state
?
''
:
'none'
;
},
400
);
}
return
this
;
},
isShow
:
function
(){
return
this
.
_show
;
},
isHide
:
function
(){
return
!
this
.
_show
;
},
setTextShape
:
function
(
text
)
{
if
(
!
text
)
{
this
.
text
=
new
kity
.
Text
();
...
...
src/module/history.js
View file @
02f04f4c
...
...
@@ -68,7 +68,9 @@ KityMinder.registerModule("HistoryModule", function() {
}
function
appendChildNode
(
parent
,
child
)
{
parent
.
appendChild
(
child
);
km
.
appendNode
(
child
,
parent
);
child
.
render
();
for
(
var
i
=
0
,
ci
;
ci
=
child
.
children
[
i
++
];)
{
appendChildNode
(
child
,
ci
);
}
...
...
@@ -101,6 +103,7 @@ KityMinder.registerModule("HistoryModule", function() {
traverseNode
(
km
.
getRoot
(),
target
);
km
.
layout
();
},
restore
:
function
()
{
var
scene
=
this
.
list
[
this
.
index
];
...
...
src/module/node.js
View file @
02f04f4c
...
...
@@ -30,7 +30,7 @@ var AppendSiblingCommand = kity.createClass('AppendSiblingCommand', {
km
.
select
(
node
,
true
);
node
.
render
();
node
.
_lastLayoutTransform
=
sibling
.
_lastLayoutTransform
;
km
.
layout
(
300
0
);
km
.
layout
(
300
);
},
queryState
:
function
(
km
)
{
var
selectedNode
=
km
.
getSelectedNode
();
...
...
src/module/select.js
View file @
02f04f4c
...
...
@@ -29,7 +29,7 @@ KityMinder.registerModule('Select', function() {
startPosition
=
g
.
snapToSharp
(
e
.
getPosition
());
},
selectMove
:
function
(
e
)
{
if
(
minder
.
isTextEditStatus
()
)
{
if
(
minder
.
getStatus
()
==
'textedit'
)
{
return
;
}
if
(
!
startPosition
)
return
;
...
...
@@ -95,7 +95,8 @@ KityMinder.registerModule('Select', function() {
var
lastDownNode
=
null
,
lastDownPosition
=
null
;
return
{
'events'
:
{
'normal.mousedown textedit.mousedown'
:
function
(
e
)
{
'normal.mousedown textedit.mousedown inputready.mousedown'
:
function
(
e
)
{
var
downNode
=
e
.
getTargetNode
();
// 没有点中节点:
...
...
@@ -127,8 +128,8 @@ KityMinder.registerModule('Select', function() {
lastDownPosition
=
e
.
getPosition
(
this
.
getRenderContainer
());
}
},
'normal.mousemove textedit.mousemove'
:
marqueeActivator
.
selectMove
,
'normal.mouseup textedit.mouseup'
:
function
(
e
)
{
'normal.mousemove textedit.mousemove
inputready.mousemove
'
:
marqueeActivator
.
selectMove
,
'normal.mouseup textedit.mouseup
inputready.mouseup
'
:
function
(
e
)
{
var
upNode
=
e
.
getTargetNode
();
// 如果 mouseup 发生在 lastDownNode 外,是无需理会的
...
...
src/module/text.js
View file @
02f04f4c
...
...
@@ -30,6 +30,11 @@ utils.extend(TextRenderer, {
}
});
kity
.
extendClass
(
MinderNode
,{
getTextShape
:
function
(){
return
this
.
getRenderer
(
'TextRenderer'
).
getRenderShape
();
}
});
KityMinder
.
registerModule
(
'text'
,
{
'renderers'
:
{
center
:
TextRenderer
...
...
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