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
0cc1fa4b
Commit
0cc1fa4b
authored
Sep 03, 2014
by
campaign
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加换行机制
parent
31c3b439
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
67 additions
and
32 deletions
+67
-32
utils.js
src/core/utils.js
+14
-3
basestyle.js
src/module/basestyle.js
+8
-4
editor.keyboard.js
src/module/editor.keyboard.js
+15
-15
editor.range.js
src/module/editor.range.js
+10
-0
font.js
src/module/font.js
+9
-5
text.js
src/module/text.js
+11
-5
No files found.
src/core/utils.js
View file @
0cc1fa4b
...
@@ -296,10 +296,21 @@ var utils = Utils = KityMinder.Utils = {
...
@@ -296,10 +296,21 @@ var utils = Utils = KityMinder.Utils = {
}
}
});
});
return
result
;
return
result
;
},
},
getNodeIndex
:
function
(
node
,
ignoreTextNode
)
{
var
preNode
=
node
,
i
=
0
;
while
(
preNode
=
preNode
.
previousSibling
)
{
if
(
ignoreTextNode
&&
preNode
.
nodeType
==
3
)
{
if
(
preNode
.
nodeType
!=
preNode
.
nextSibling
.
nodeType
){
i
++
;
}
continue
;
}
i
++
;
}
return
i
;
}
};
};
...
...
src/module/basestyle.js
View file @
0cc1fa4b
...
@@ -5,11 +5,15 @@ KityMinder.registerModule('basestylemodule', function() {
...
@@ -5,11 +5,15 @@ KityMinder.registerModule('basestylemodule', function() {
return
node
.
getData
(
name
)
||
node
.
getStyle
(
name
);
return
node
.
getData
(
name
)
||
node
.
getStyle
(
name
);
}
}
KityMinder
.
TextRenderer
.
registerStyleHook
(
function
(
node
,
text
)
{
KityMinder
.
TextRenderer
.
registerStyleHook
(
function
(
node
,
textGroup
)
{
text
.
setFont
({
weight
:
getNodeDataOrStyle
(
node
,
'font-weight'
),
textGroup
.
eachItem
(
function
(
index
,
item
){
style
:
getNodeDataOrStyle
(
node
,
'font-style'
)
item
.
setFont
({
'weight'
:
getNodeDataOrStyle
(
node
,
'font-weight'
),
'style'
:
getNodeDataOrStyle
(
node
,
'font-style'
)
});
});
});
});
});
return
{
return
{
'commands'
:
{
'commands'
:
{
...
...
src/module/editor.keyboard.js
View file @
0cc1fa4b
...
@@ -53,7 +53,6 @@ Minder.keyboarder = kity.createClass('keyboarder', function(){
...
@@ -53,7 +53,6 @@ Minder.keyboarder = kity.createClass('keyboarder', function(){
}
}
},
},
_setTextToContainer
:
function
(
keyCode
){
_setTextToContainer
:
function
(
keyCode
){
var
me
=
this
;
var
me
=
this
;
//同步节点
//同步节点
me
.
minderNode
=
me
.
re
.
minderNode
;
me
.
minderNode
=
me
.
re
.
minderNode
;
...
@@ -116,7 +115,6 @@ Minder.keyboarder = kity.createClass('keyboarder', function(){
...
@@ -116,7 +115,6 @@ Minder.keyboarder = kity.createClass('keyboarder', function(){
}
}
},
200
);
},
200
);
me
.
km
.
setStatus
(
'textedit'
);
me
.
km
.
setStatus
(
'textedit'
);
},
},
_input
:
function
(
e
){
_input
:
function
(
e
){
...
@@ -137,7 +135,9 @@ Minder.keyboarder = kity.createClass('keyboarder', function(){
...
@@ -137,7 +135,9 @@ Minder.keyboarder = kity.createClass('keyboarder', function(){
switch
(
keyCode
)
{
switch
(
keyCode
)
{
case
keymap
.
Enter
:
case
keymap
.
Enter
:
if
(
e
.
originEvent
.
shiftKey
){
if
(
e
.
originEvent
.
shiftKey
){
return
;
me
.
_handlerEnterkey
();
e
.
preventDefault
();
return
false
;
}
}
case
keymap
.
Tab
:
case
keymap
.
Tab
:
if
(
this
.
selection
.
isShow
()){
if
(
this
.
selection
.
isShow
()){
...
@@ -222,11 +222,6 @@ Minder.keyboarder = kity.createClass('keyboarder', function(){
...
@@ -222,11 +222,6 @@ Minder.keyboarder = kity.createClass('keyboarder', function(){
switch
(
keyCode
)
{
switch
(
keyCode
)
{
case
keymap
.
Enter
:
case
keymap
.
Enter
:
if
(
e
.
originEvent
.
shiftKey
){
me
.
_setTextToContainer
(
keyCode
);
return
;
}
case
keymap
.
Tab
:
case
keymap
.
Tab
:
case
keymap
.
F2
:
case
keymap
.
F2
:
if
(
browser
.
ipad
){
if
(
browser
.
ipad
){
...
@@ -279,7 +274,6 @@ Minder.keyboarder = kity.createClass('keyboarder', function(){
...
@@ -279,7 +274,6 @@ Minder.keyboarder = kity.createClass('keyboarder', function(){
var
me
=
this
;
var
me
=
this
;
var
orgEvt
=
e
.
originEvent
;
var
orgEvt
=
e
.
originEvent
;
var
keyCode
=
orgEvt
.
keyCode
;
var
keyCode
=
orgEvt
.
keyCode
;
var
node
=
this
.
km
.
getSelectedNode
();
var
node
=
this
.
km
.
getSelectedNode
();
if
(
this
.
km
.
getStatus
()
==
'normal'
&&
node
&&
this
.
selection
.
isHide
()){
if
(
this
.
km
.
getStatus
()
==
'normal'
&&
node
&&
this
.
selection
.
isHide
()){
if
(
node
&&
this
.
km
.
isSingleSelect
()
&&
node
.
isSelected
())
{
if
(
node
&&
this
.
km
.
isSingleSelect
()
&&
node
.
isSelected
())
{
...
@@ -306,17 +300,23 @@ Minder.keyboarder = kity.createClass('keyboarder', function(){
...
@@ -306,17 +300,23 @@ Minder.keyboarder = kity.createClass('keyboarder', function(){
});
});
}
}
this
.
km
.
setStatus
(
'inputready'
);
this
.
km
.
setStatus
(
'inputready'
);
}
}
}
}
},
},
_handlerEnterkey
:
function
(
e
){
_handlerEnterkey
:
function
(){
var
textArr
=
[];
var
rng
=
this
.
range
;
utils
.
each
(
this
.
container
.
childNodes
,
function
(
index
,
node
){
var
br
=
document
.
createElement
(
'br'
);
textArr
.
push
(
node
.
nodeType
==
1
?
'
\
n'
:
utils
.
clearWhitespace
(
node
.
nodeValue
));
var
me
=
this
;
})
if
(
!
rng
.
collapsed
){
rng
.
deleteContents
();
}
rng
.
insertNode
(
br
);
rng
.
setStartAfter
(
br
);
rng
.
collapse
(
true
);
rng
.
select
();
me
.
_setTextToContainer
(
keymap
.
Enter
);
}
}
...
...
src/module/editor.range.js
View file @
0cc1fa4b
...
@@ -7,6 +7,9 @@ Minder.Range = kity.createClass('Range',function(){
...
@@ -7,6 +7,9 @@ Minder.Range = kity.createClass('Range',function(){
if
(
node
.
nodeType
==
1
){
if
(
node
.
nodeType
==
1
){
//默认不会出现得不到子节点的情况
//默认不会出现得不到子节点的情况
node
=
node
.
childNodes
[
offset
];
node
=
node
.
childNodes
[
offset
];
if
(
node
.
nodeType
==
3
){
offset
=
0
;
}
}
}
utils
.
each
(
rng
.
container
.
childNodes
,
function
(
index
,
n
){
utils
.
each
(
rng
.
container
.
childNodes
,
function
(
index
,
n
){
if
(
n
===
node
){
if
(
n
===
node
){
...
@@ -57,6 +60,10 @@ Minder.Range = kity.createClass('Range',function(){
...
@@ -57,6 +60,10 @@ Minder.Range = kity.createClass('Range',function(){
hasNativeRange
:
function
(){
hasNativeRange
:
function
(){
return
this
.
nativeSel
.
rangeCount
!==
0
;
return
this
.
nativeSel
.
rangeCount
!==
0
;
},
},
deleteContents
:
function
(){
this
.
nativeRange
.
deleteContents
();
return
this
.
_updateBoundary
();
},
select
:
function
(){
select
:
function
(){
var
start
=
this
.
nativeRange
.
startContainer
;
var
start
=
this
.
nativeRange
.
startContainer
;
if
(
start
.
nodeType
==
1
&&
start
.
childNodes
.
length
===
0
){
if
(
start
.
nodeType
==
1
&&
start
.
childNodes
.
length
===
0
){
...
@@ -98,6 +105,9 @@ Minder.Range = kity.createClass('Range',function(){
...
@@ -98,6 +105,9 @@ Minder.Range = kity.createClass('Range',function(){
this
.
_updateBoundary
();
this
.
_updateBoundary
();
return
this
;
return
this
;
},
},
setStartAfter
:
function
(
node
){
return
this
.
setStart
(
node
.
parentNode
,
utils
.
getNodeIndex
(
node
)
+
1
);
},
setEnd
:
function
(
node
,
offset
){
setEnd
:
function
(
node
,
offset
){
this
.
nativeRange
.
setEnd
(
node
,
offset
);
this
.
nativeRange
.
setEnd
(
node
,
offset
);
this
.
_updateBoundary
();
this
.
_updateBoundary
();
...
...
src/module/font.js
View file @
0cc1fa4b
...
@@ -3,14 +3,18 @@ KityMinder.registerModule("fontmodule", function() {
...
@@ -3,14 +3,18 @@ KityMinder.registerModule("fontmodule", function() {
return
node
.
getData
(
name
)
||
node
.
getStyle
(
name
);
return
node
.
getData
(
name
)
||
node
.
getStyle
(
name
);
}
}
KityMinder
.
TextRenderer
.
registerStyleHook
(
function
(
node
,
text
)
{
KityMinder
.
TextRenderer
.
registerStyleHook
(
function
(
node
,
text
Group
)
{
var
dataColor
=
node
.
getData
(
'color'
);
var
dataColor
=
node
.
getData
(
'color'
);
var
selectedColor
=
node
.
getStyle
(
'selected-color'
);
var
selectedColor
=
node
.
getStyle
(
'selected-color'
);
var
styleColor
=
node
.
getStyle
(
'color'
);
var
styleColor
=
node
.
getStyle
(
'color'
);
text
.
fill
(
dataColor
||
(
node
.
isSelected
()
&&
selectedColor
?
selectedColor
:
styleColor
));
textGroup
.
fill
(
dataColor
||
(
node
.
isSelected
()
&&
selectedColor
?
selectedColor
:
styleColor
));
text
.
setFont
({
family
:
getNodeDataOrStyle
(
node
,
'font-family'
),
size
:
getNodeDataOrStyle
(
node
,
'font-size'
)
textGroup
.
eachItem
(
function
(
index
,
item
){
item
.
setFont
({
'family'
:
getNodeDataOrStyle
(
node
,
'font-family'
),
'size'
:
getNodeDataOrStyle
(
node
,
'font-size'
)
});
});
});
});
});
...
...
src/module/text.js
View file @
0cc1fa4b
...
@@ -22,8 +22,8 @@ var TextRenderer = KityMinder.TextRenderer = kity.createClass('TextRenderer', {
...
@@ -22,8 +22,8 @@ var TextRenderer = KityMinder.TextRenderer = kity.createClass('TextRenderer', {
r
=
Math
.
round
;
r
=
Math
.
round
;
this
.
setTextStyle
(
node
,
textGroup
);
this
.
setTextStyle
(
node
,
textGroup
);
for
(
var
i
=
0
,
text
,
textShape
;
for
(
var
i
=
0
,
text
,
textShape
;
(
text
=
textArr
[
i
],
textShape
=
textGroup
.
getItem
(
i
),
(
text
=
textArr
[
i
],
textShape
=
textGroup
.
getItem
(
i
),
...
@@ -40,13 +40,19 @@ var TextRenderer = KityMinder.TextRenderer = kity.createClass('TextRenderer', {
...
@@ -40,13 +40,19 @@ var TextRenderer = KityMinder.TextRenderer = kity.createClass('TextRenderer', {
}
}
textShape
.
setContent
(
text
);
textShape
.
setContent
(
text
);
var
y
=
i
*
fontSize
*
lineHeight
-
height
;
textShape
.
setY
(
y
);
rBox
=
rBox
.
merge
(
new
kity
.
Box
(
0
,
y
,
textShape
.
getBoundaryBox
().
width
,
fontSize
));
}
}
}
}
this
.
setTextStyle
(
node
,
textGroup
);
textGroup
.
eachItem
(
function
(
i
,
textShape
){
var
y
=
i
*
fontSize
*
lineHeight
-
height
;
textShape
.
setY
(
y
);
rBox
=
rBox
.
merge
(
new
kity
.
Box
(
0
,
y
,
textShape
.
getBoundaryBox
().
width
,
fontSize
));
});
var
nBox
=
new
kity
.
Box
(
r
(
rBox
.
x
),
r
(
rBox
.
y
),
r
(
rBox
.
width
),
r
(
rBox
.
height
));
var
nBox
=
new
kity
.
Box
(
r
(
rBox
.
x
),
r
(
rBox
.
y
),
r
(
rBox
.
width
),
r
(
rBox
.
height
));
...
...
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