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
7862e551
Commit
7862e551
authored
Mar 18, 2014
by
Akikonata
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dev' of
https://github.com/fex-team/kityminder
into dev
parents
effcf515
5dc8b28e
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
77 additions
and
27 deletions
+77
-27
CHANGELOG.md
CHANGELOG.md
+8
-0
keymap.js
src/core/keymap.js
+5
-2
minder.event.js
src/core/minder.event.js
+1
-1
editor.range.js
src/module/editor.range.js
+6
-0
editor.receiver.js
src/module/editor.receiver.js
+54
-24
select.js
src/module/select.js
+3
-0
No files found.
CHANGELOG.md
0 → 100644
View file @
7862e551
# KityMinder Change List
## 1.1.0
### 功能更新
1.
添加了粘贴剪贴复制功能
### 问题修复
src/core/keymap.js
View file @
7862e551
...
@@ -35,7 +35,10 @@ var keymap = KityMinder.keymap = {
...
@@ -35,7 +35,10 @@ var keymap = KityMinder.keymap = {
"b"
:
66
,
"b"
:
66
,
'i'
:
73
,
'i'
:
73
,
//回退
'z'
:
90
,
'z'
:
90
,
'y'
:
89
'y'
:
89
,
//粘贴
'v'
:
86
,
'x'
:
88
};
};
\ No newline at end of file
src/core/minder.event.js
View file @
7862e551
...
@@ -21,7 +21,7 @@ kity.extendClass( Minder, {
...
@@ -21,7 +21,7 @@ kity.extendClass( Minder, {
_bindKeyboardEvents
:
function
()
{
_bindKeyboardEvents
:
function
()
{
if
(
(
navigator
.
userAgent
.
indexOf
(
'iPhone'
)
==
-
1
)
&&
(
navigator
.
userAgent
.
indexOf
(
'iPod'
)
==
-
1
)
&&
(
navigator
.
userAgent
.
indexOf
(
'iPad'
)
==
-
1
)
)
{
if
(
(
navigator
.
userAgent
.
indexOf
(
'iPhone'
)
==
-
1
)
&&
(
navigator
.
userAgent
.
indexOf
(
'iPod'
)
==
-
1
)
&&
(
navigator
.
userAgent
.
indexOf
(
'iPad'
)
==
-
1
)
)
{
//只能在这里做,要不无法触发
//只能在这里做,要不无法触发
Utils
.
listen
(
document
.
body
,
'keydown keyup keypress'
,
this
.
_firePharse
.
bind
(
this
)
);
Utils
.
listen
(
document
.
body
,
'keydown keyup keypress
paste
'
,
this
.
_firePharse
.
bind
(
this
)
);
}
}
},
},
_firePharse
:
function
(
e
)
{
_firePharse
:
function
(
e
)
{
...
...
src/module/editor.range.js
View file @
7862e551
...
@@ -35,6 +35,7 @@ Minder.Range = kity.createClass('Range',{
...
@@ -35,6 +35,7 @@ Minder.Range = kity.createClass('Range',{
startOffset
:
range
.
startOffset
startOffset
:
range
.
startOffset
}
}
},
},
collapse
:
function
(
toStart
){
collapse
:
function
(
toStart
){
this
.
nativeRange
.
collapse
(
toStart
===
true
);
this
.
nativeRange
.
collapse
(
toStart
===
true
);
return
this
;
return
this
;
...
@@ -42,5 +43,10 @@ Minder.Range = kity.createClass('Range',{
...
@@ -42,5 +43,10 @@ Minder.Range = kity.createClass('Range',{
insertNode
:
function
(
node
){
insertNode
:
function
(
node
){
this
.
nativeRange
.
insertNode
(
node
);
this
.
nativeRange
.
insertNode
(
node
);
return
this
;
return
this
;
},
updateNativeRange
:
function
(){
this
.
nativeRange
=
this
.
nativeSel
.
getRangeAt
(
0
);
return
this
;
}
}
});
});
\ No newline at end of file
src/module/editor.receiver.js
View file @
7862e551
...
@@ -5,6 +5,7 @@ Minder.Receiver = kity.createClass('Receiver',{
...
@@ -5,6 +5,7 @@ Minder.Receiver = kity.createClass('Receiver',{
this
.
selection
&&
this
.
selection
.
setHide
();
this
.
selection
&&
this
.
selection
.
setHide
();
this
.
range
&&
this
.
range
.
nativeSel
.
removeAllRanges
();
this
.
range
&&
this
.
range
.
nativeSel
.
removeAllRanges
();
this
.
index
=
0
;
this
.
index
=
0
;
this
.
inputLength
=
0
;
return
this
;
return
this
;
},
},
setTextEditStatus
:
function
(
status
){
setTextEditStatus
:
function
(
status
){
...
@@ -21,8 +22,8 @@ Minder.Receiver = kity.createClass('Receiver',{
...
@@ -21,8 +22,8 @@ Minder.Receiver = kity.createClass('Receiver',{
_div
.
setAttribute
(
'contenteditable'
,
true
);
_div
.
setAttribute
(
'contenteditable'
,
true
);
_div
.
className
=
'km_receiver'
;
_div
.
className
=
'km_receiver'
;
this
.
container
=
document
.
body
.
insertBefore
(
_div
,
document
.
body
.
firstChild
);
this
.
container
=
document
.
body
.
insertBefore
(
_div
,
document
.
body
.
firstChild
);
utils
.
addCssRule
(
'km_receiver_css'
,
' .km_receiver{position:absolute;padding:0;margin:0;word-wrap:break-word;
clip:rect(1em 1em 1em 1em);}'
);
//
utils
.
addCssRule
(
'km_receiver_css'
,
' .km_receiver{position:absolute;padding:0;margin:0;word-wrap:break-word;
}'
);
//clip:rect(1em 1em 1em 1em);
this
.
km
.
on
(
'textedit.beforekeyup textedit.keydown'
,
utils
.
proxy
(
this
.
keyboardEvents
,
this
));
this
.
km
.
on
(
'textedit.beforekeyup textedit.keydown
textedit.paste
'
,
utils
.
proxy
(
this
.
keyboardEvents
,
this
));
this
.
timer
=
null
;
this
.
timer
=
null
;
this
.
index
=
0
;
this
.
index
=
0
;
},
},
...
@@ -74,8 +75,32 @@ Minder.Receiver = kity.createClass('Receiver',{
...
@@ -74,8 +75,32 @@ Minder.Receiver = kity.createClass('Receiver',{
var
orgEvt
=
e
.
originEvent
;
var
orgEvt
=
e
.
originEvent
;
var
keyCode
=
orgEvt
.
keyCode
;
var
keyCode
=
orgEvt
.
keyCode
;
var
keys
=
KityMinder
.
keymap
;
var
keys
=
KityMinder
.
keymap
;
function
setTextToContainer
(){
var
text
=
me
.
container
.
textContent
.
replace
(
/
[\u
200b
\t\r\n]
/g
,
''
);
if
(
me
.
textShape
.
getOpacity
()
==
0
){
me
.
textShape
.
setOpacity
(
1
);
}
me
.
textShape
.
setContent
(
text
);
me
.
setContainerStyle
();
me
.
minderNode
.
setText
(
text
);
if
(
text
.
length
==
0
){
me
.
textShape
.
setContent
(
'a'
);
me
.
textShape
.
setOpacity
(
0
);
}
me
.
km
.
updateLayout
(
me
.
minderNode
);
me
.
setBaseOffset
();
me
.
updateTextData
();
me
.
updateIndex
();
me
.
updateSelection
();
me
.
timer
=
setTimeout
(
function
(){
me
.
selection
.
setShow
()
},
500
);
}
switch
(
e
.
type
){
switch
(
e
.
type
){
case
'keydown'
:
case
'keydown'
:
switch
(
e
.
originEvent
.
keyCode
)
{
switch
(
e
.
originEvent
.
keyCode
)
{
case
keys
.
Enter
:
case
keys
.
Enter
:
...
@@ -86,8 +111,33 @@ Minder.Receiver = kity.createClass('Receiver',{
...
@@ -86,8 +111,33 @@ Minder.Receiver = kity.createClass('Receiver',{
e
.
preventDefault
();
e
.
preventDefault
();
break
;
break
;
}
}
if
(
e
.
originEvent
.
ctrlKey
||
e
.
originEvent
.
metaKey
){
//粘贴
if
(
keyCode
==
keymap
.
v
){
setTimeout
(
function
(){
me
.
range
.
updateNativeRange
().
insertNode
(
$
(
'<span>$$_kityminder_bookmark_$$</span>'
)[
0
]);
me
.
container
.
innerHTML
=
me
.
container
.
textContent
.
replace
(
/
[\u
200b
\t\r\n]
/g
,
''
);
var
index
=
me
.
container
.
textContent
.
indexOf
(
'$$_kityminder_bookmark_$$'
);
me
.
container
.
textContent
=
me
.
container
.
textContent
.
replace
(
'$$_kityminder_bookmark_$$'
,
''
);
me
.
range
.
setStart
(
me
.
container
.
firstChild
,
index
).
collapse
(
true
).
select
();
setTextToContainer
()
},
100
);
}
//剪切
if
(
keyCode
==
keymap
.
x
){
setTimeout
(
function
(){
setTextToContainer
()
},
100
);
}
return
;
}
break
;
break
;
case
'beforekeyup'
:
case
'beforekeyup'
:
switch
(
keyCode
){
switch
(
keyCode
){
case
keymap
.
Enter
:
case
keymap
.
Enter
:
case
keymap
.
Tab
:
case
keymap
.
Tab
:
...
@@ -105,34 +155,14 @@ Minder.Receiver = kity.createClass('Receiver',{
...
@@ -105,34 +155,14 @@ Minder.Receiver = kity.createClass('Receiver',{
return
;
return
;
}
}
var
text
=
this
.
container
.
textContent
.
replace
(
/
\u
200b/g
,
''
);
if
(
this
.
textShape
.
getOpacity
()
==
0
){
this
.
textShape
.
setOpacity
(
1
);
}
this
.
textShape
.
setContent
(
text
);
this
.
setContainerStyle
();
this
.
minderNode
.
setText
(
text
);
if
(
text
.
length
==
0
){
this
.
textShape
.
setContent
(
'a'
);
this
.
textShape
.
setOpacity
(
0
);
}
this
.
km
.
updateLayout
(
this
.
minderNode
);
this
.
setBaseOffset
();
this
.
updateTextData
();
this
.
updateIndex
();
this
.
updateSelection
();
this
.
timer
=
setTimeout
(
function
(){
setTextToContainer
();
me
.
selection
.
setShow
()
},
500
);
return
true
;
return
true
;
}
}
},
},
updateIndex
:
function
(){
updateIndex
:
function
(){
this
.
index
=
this
.
range
.
getStart
().
startOffset
;
this
.
index
=
this
.
range
.
getStart
().
startOffset
;
},
},
...
...
src/module/select.js
View file @
7862e551
...
@@ -101,6 +101,9 @@ KityMinder.registerModule( "Select", function () {
...
@@ -101,6 +101,9 @@ KityMinder.registerModule( "Select", function () {
if
(
!
downNode
)
{
if
(
!
downNode
)
{
this
.
removeAllSelectedNodes
();
this
.
removeAllSelectedNodes
();
marqueeActivator
.
selectStart
(
e
);
marqueeActivator
.
selectStart
(
e
);
if
(
this
.
getStatus
()
==
'textedit'
){
this
.
trigger
(
'contentchange'
)
}
this
.
setStatus
(
'normal'
)
this
.
setStatus
(
'normal'
)
}
}
...
...
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