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
82e40daf
Commit
82e40daf
authored
Jun 24, 2014
by
campaign
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
改变光标策略适应拖拽策略
parent
f073a7f3
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
89 additions
and
101 deletions
+89
-101
editor.js
src/module/editor.js
+66
-67
editor.receiver.js
src/module/editor.receiver.js
+23
-24
editor.selection.js
src/module/editor.selection.js
+0
-10
No files found.
src/module/editor.js
View file @
82e40daf
...
...
@@ -82,7 +82,7 @@ KityMinder.registerModule('TextEditModule', function() {
if
(
this
.
isSingleSelect
()
&&
node
.
isSelected
()
&&
hasCursor
)
{
sel
.
collapse
();
sel
.
setSelectionShowStatus
(
true
);
node
.
getRenderer
(
'TextRenderer'
).
getRenderShape
().
setStyle
(
'cursor'
,
'text'
);
receiver
.
setTextEditStatus
(
true
)
...
...
@@ -114,69 +114,69 @@ KityMinder.registerModule('TextEditModule', function() {
}
},
//当输入键值是内容时,进入textedit状态
'normal.beforekeydown'
:
function
(
e
)
{
var
node
=
this
.
getSelectedNode
();
if
(
node
)
{
if
(
this
.
isSingleSelect
()
&&
node
.
isSelected
())
{
var
orgEvt
=
e
.
originEvent
,
keyCode
=
orgEvt
.
keyCode
;
if
(
!
keymap
.
notContentInput
[
keyCode
]
&&
range
.
nativeSel
.
rangeCount
!==
0
&&
!
orgEvt
.
ctrlKey
&&
!
orgEvt
.
metaKey
&&
!
orgEvt
.
shiftKey
&&
!
orgEvt
.
altKey
)
{
var
nativeRange
=
range
.
nativeSel
.
getRangeAt
(
0
);
if
(
nativeRange
&&
(
nativeRange
.
startContainer
===
receiver
.
container
||
receiver
.
container
.
contains
(
nativeRange
.
startContainer
)))
{
km
.
setStatus
(
'textedit'
);
sel
.
setSelectionShowStatus
(
true
);
km
.
fire
(
'saveScene'
);
}
}
}
}
},
//当节点选区通过键盘发生变化时,输入状态要准备好
'normal.keyup'
:
function
(
e
)
{
var
node
=
this
.
getSelectedNode
();
if
(
node
)
{
if
(
this
.
isSingleSelect
()
&&
node
.
isSelected
())
{
var
orgEvt
=
e
.
originEvent
,
keyCode
=
orgEvt
.
keyCode
;
if
(
keymap
.
isSelectedNodeKey
[
keyCode
]
&&
km
.
getStatus
()
!=
'textedit'
&&
!
orgEvt
.
ctrlKey
&&
!
orgEvt
.
metaKey
&&
!
orgEvt
.
shiftKey
&&
!
orgEvt
.
altKey
)
{
//准备输入状态
var
textShape
=
node
.
getRenderer
(
'TextRenderer'
).
getRenderShape
();
sel
.
setHide
();
sel
.
setStartOffset
(
0
);
sel
.
setEndOffset
(
textShape
.
getContent
().
length
);
sel
.
setSelectionShowStatus
(
true
);
receiver
.
setTextEditStatus
(
true
)
.
setSelection
(
sel
)
.
setKityMinder
(
this
)
.
setMinderNode
(
node
)
.
setTextShape
(
textShape
)
.
setRange
(
range
)
.
setBaseOffset
()
.
setContainerStyle
()
.
setSelectionHeight
()
.
setContainerTxt
(
textShape
.
getContent
())
.
updateRange
(
range
).
setTextEditStatus
(
true
);
sel
.
setData
(
'relatedNode'
,
node
);
}
}
}
},
//
//当输入键值是内容时,进入textedit状态
//
'normal.beforekeydown': function(e) {
//
var node = this.getSelectedNode();
//
if (node) {
//
if (this.isSingleSelect() && node.isSelected()) {
//
var orgEvt = e.originEvent,
//
keyCode = orgEvt.keyCode;
//
if (!keymap.notContentInput[keyCode] &&
//
range.nativeSel.rangeCount !== 0 &&
//
!orgEvt.ctrlKey && !orgEvt.metaKey &&
//
!orgEvt.shiftKey && !orgEvt.altKey) {
//
//
var nativeRange = range.nativeSel.getRangeAt(0);
//
if (nativeRange && (nativeRange.startContainer === receiver.container ||
//
receiver.container.contains(nativeRange.startContainer))) {
//
km.setStatus('textedit');
//
sel.setSelectionShowStatus(true);
//
km.fire('saveScene');
//
}
//
//
}
//
}
//
}
//
},
//
//当节点选区通过键盘发生变化时,输入状态要准备好
//
'normal.keyup': function(e) {
//
var node = this.getSelectedNode();
//
if (node) {
//
if (this.isSingleSelect() && node.isSelected()) {
//
var orgEvt = e.originEvent,
//
keyCode = orgEvt.keyCode;
//
if (keymap.isSelectedNodeKey[keyCode] &&
//
km.getStatus() != 'textedit' &&
//
!orgEvt.ctrlKey &&
//
!orgEvt.metaKey &&
//
!orgEvt.shiftKey &&
//
!orgEvt.altKey) {
//
//
//准备输入状态
//
var textShape = node.getRenderer('TextRenderer').getRenderShape();
//
//
sel.setHide();
//
sel.setStartOffset(0);
//
sel.setEndOffset(textShape.getContent().length);
//
sel.setSelectionShowStatus(true);
//
receiver.setTextEditStatus(true)
//
.setSelection(sel)
//
.setKityMinder(this)
//
.setMinderNode(node)
//
.setTextShape(textShape)
//
.setRange(range)
//
.setBaseOffset()
//
.setContainerStyle()
//
.setSelectionHeight()
//
.setContainerTxt(textShape.getContent())
//
.updateRange(range).setTextEditStatus(true);
//
//
sel.setData('relatedNode', node);
//
}
//
}
//
}
//
},
'normal.mouseup textedit.mouseup'
:
function
(
e
)
{
var
node
=
e
.
getTargetNode
();
...
...
@@ -185,9 +185,8 @@ KityMinder.registerModule('TextEditModule', function() {
var
textShape
=
node
.
getRenderer
(
'TextRenderer'
).
getRenderShape
();
if
(
isSelected
&&
!
hasCursor
)
{
console
.
log
(
'sd'
)
sel
.
collapse
();
sel
.
setSelectionShowStatus
(
true
);
node
.
getRenderer
(
'TextRenderer'
).
getRenderShape
().
setStyle
(
'cursor'
,
'text'
);
receiver
.
setTextEditStatus
(
true
)
...
...
@@ -306,7 +305,7 @@ KityMinder.registerModule('TextEditModule', function() {
sel
.
setHide
();
sel
.
setStartOffset
(
0
);
sel
.
setEndOffset
(
textShape
.
getContent
().
length
);
sel
.
setSelectionShowStatus
(
false
);
receiver
.
setTextEditStatus
(
true
)
.
setSelection
(
sel
)
.
setKityMinder
(
this
)
...
...
src/module/editor.receiver.js
View file @
82e40daf
...
...
@@ -33,7 +33,7 @@ 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.keydown textedit.keypress textedit.paste'
,
utils
.
proxy
(
this
.
keyboardEvents
,
this
));
this
.
km
.
on
(
'textedit.beforekeyup textedit.
before
keydown textedit.keypress textedit.paste'
,
utils
.
proxy
(
this
.
keyboardEvents
,
this
));
this
.
timer
=
null
;
this
.
index
=
0
;
},
...
...
@@ -105,7 +105,12 @@ Minder.Receiver = kity.createClass('Receiver', {
me
.
minderNode
.
setText
(
'a'
);
}
me
.
setContainerStyle
();
me
.
minderNode
.
render
().
layout
();
me
.
minderNode
.
getRenderContainer
().
bringTop
();
me
.
minderNode
.
render
();
clearTimeout
(
me
.
inputTextTimer
);
me
.
inputTextTimer
=
setTimeout
(
function
(){
me
.
km
.
layout
(
300
);
},
250
);
me
.
textShape
=
me
.
minderNode
.
getRenderer
(
'TextRenderer'
).
getRenderShape
();
if
(
text
.
length
===
0
)
{
...
...
@@ -116,13 +121,10 @@ Minder.Receiver = kity.createClass('Receiver', {
me
.
updateIndex
();
if
(
me
.
selection
.
getSelectionShowStatus
())
{
me
.
updateSelection
();
me
.
timer
=
setTimeout
(
function
()
{
me
.
selection
.
setShow
();
},
500
);
}
me
.
updateSelection
();
me
.
timer
=
setTimeout
(
function
()
{
me
.
selection
.
setShow
();
},
300
);
}
...
...
@@ -137,16 +139,18 @@ Minder.Receiver = kity.createClass('Receiver', {
}
break
;
case
'keydown'
:
case
'
before
keydown'
:
this
.
isTypeText
=
keyCode
==
229
||
keyCode
===
0
;
switch
(
keyCode
)
{
case
keys
.
Enter
:
case
keys
.
Tab
:
this
.
selection
.
setHide
();
this
.
clear
().
setTextEditStatus
(
false
);
this
.
km
.
fire
(
'contentchange'
);
this
.
km
.
setStatus
(
'normal'
);
e
.
preventDefault
();
case
keymap
.
Enter
:
case
keymap
.
Tab
:
if
(
this
.
selection
.
isShow
()){
this
.
clear
().
setTextEditStatus
(
false
);
e
.
preventDefault
();
}
else
{
this
.
km
.
setStatus
(
'normal'
);
this
.
km
.
fire
(
'contentchange'
);
}
return
;
case
keymap
.
Shift
:
case
keymap
.
Control
:
...
...
@@ -189,6 +193,7 @@ Minder.Receiver = kity.createClass('Receiver', {
case
keymap
.
F2
:
if
(
keymap
.
Enter
==
keyCode
&&
(
this
.
isTypeText
||
browser
.
mac
&&
browser
.
gecko
))
{
setTextToContainer
();
}
if
(
this
.
keydownNode
===
this
.
minderNode
)
{
this
.
rollbackStatus
();
...
...
@@ -203,7 +208,6 @@ Minder.Receiver = kity.createClass('Receiver', {
setTextToContainer
();
return
;
}
if
(
this
.
isTypeText
)
{
setTextToContainer
();
}
...
...
@@ -248,12 +252,7 @@ Minder.Receiver = kity.createClass('Receiver', {
return
this
;
},
getBaseOffset
:
function
(
refer
)
{
var
rb
=
this
.
textShape
.
getRenderBox
(
refer
||
this
.
km
.
getRenderContainer
());
// if(!this.pr) {
// this.km.getRenderContainer().addShape(this.pr = new kity.Rect().stroke('green'));
// }
// this.pr.setSize(rb.width, rb.height).setPosition(rb.x, rb.y);
return
rb
;
return
this
.
textShape
.
getRenderBox
(
refer
||
this
.
km
.
getRenderContainer
());
},
setBaseOffset
:
function
()
{
this
.
offset
=
this
.
textShape
.
getRenderBox
(
this
.
km
.
getRenderContainer
());
...
...
src/module/editor.selection.js
View file @
82e40daf
...
...
@@ -104,7 +104,6 @@ Minder.Selection = kity.createClass( 'Selection', {
var
me
=
this
,
state
=
''
;
me
.
setStyle
(
'display'
,
''
);
this
.
setSelectionShowStatus
(
true
);
me
.
_show
=
true
;
if
(
this
.
collapsed
){
me
.
setOpacity
(
1
);
...
...
@@ -132,14 +131,5 @@ Minder.Selection = kity.createClass( 'Selection', {
},
setTxtContent
:
function
(
text
)
{
this
.
text
.
setContent
(
text
);
},
updatePosition
:
function
(
index
)
{
},
setSelectionShowStatus
:
function
(
status
){
this
.
selectionShowStatus
=
status
;
},
getSelectionShowStatus
:
function
(){
return
this
.
selectionShowStatus
;
}
}
);
\ 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