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
158f30b6
Commit
158f30b6
authored
Feb 11, 2014
by
Akikonata
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dev' of
https://github.com/kitygraph/kityminder
into dev
parents
92a78d6f
1fc93a5a
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
102 additions
and
93 deletions
+102
-93
basestyle.js
src/module/basestyle.js
+4
-0
editor.receiver.js
src/module/editor.receiver.js
+96
-93
font.js
src/module/font.js
+2
-0
No files found.
src/module/basestyle.js
View file @
158f30b6
...
...
@@ -13,11 +13,13 @@ KityMinder.registerModule( "basestylemodule", function () {
utils
.
each
(
nodes
,
function
(
i
,
n
){
n
.
setData
(
'bold'
);
n
.
getTextShape
().
setAttr
(
'font-weight'
);
km
.
updateLayout
(
n
)
})
}
else
{
utils
.
each
(
nodes
,
function
(
i
,
n
){
n
.
setData
(
'bold'
,
true
);
n
.
getTextShape
().
setAttr
(
'font-weight'
,
'bold'
);
km
.
updateLayout
(
n
)
})
}
},
...
...
@@ -43,11 +45,13 @@ KityMinder.registerModule( "basestylemodule", function () {
utils
.
each
(
nodes
,
function
(
i
,
n
){
n
.
setData
(
'italic'
);
n
.
getTextShape
().
setAttr
(
'font-style'
);
km
.
updateLayout
(
n
)
})
}
else
{
utils
.
each
(
nodes
,
function
(
i
,
n
){
n
.
setData
(
'italic'
,
true
);
n
.
getTextShape
().
setAttr
(
'font-style'
,
'italic'
);
km
.
updateLayout
(
n
)
})
}
},
...
...
src/module/editor.receiver.js
View file @
158f30b6
//接收者
Minder
.
Receiver
=
kity
.
createClass
(
'Receiver'
,
{
clear
:
function
()
{
Minder
.
Receiver
=
kity
.
createClass
(
'Receiver'
,
{
clear
:
function
()
{
this
.
container
.
innerHTML
=
''
;
this
.
cursor
.
setHide
();
this
.
index
=
0
;
return
this
;
},
setTextEditStatus
:
function
(
status
)
{
setTextEditStatus
:
function
(
status
)
{
this
.
textEditStatus
=
status
||
false
;
return
this
;
},
isTextEditStatus
:
function
()
{
isTextEditStatus
:
function
()
{
return
this
.
textEditStatus
;
},
constructor
:
function
(
km
)
{
this
.
setKityMinder
(
km
);
constructor
:
function
(
km
)
{
this
.
setKityMinder
(
km
);
this
.
textEditStatus
=
false
;
var
_div
=
document
.
createElement
(
'div'
);
_div
.
setAttribute
(
'contenteditable'
,
true
);
var
_div
=
document
.
createElement
(
'div'
);
_div
.
setAttribute
(
'contenteditable'
,
true
);
_div
.
className
=
'km_receiver'
;
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);}'
);
//
this
.
km
.
on
(
'beforekeyup'
,
utils
.
proxy
(
this
.
keyboardEvents
,
this
)
);
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);}'
);
//
this
.
km
.
on
(
'beforekeyup'
,
utils
.
proxy
(
this
.
keyboardEvents
,
this
)
);
this
.
timer
=
null
;
this
.
index
=
0
;
},
setRange
:
function
(
range
,
index
)
{
setRange
:
function
(
range
,
index
)
{
this
.
index
=
index
||
this
.
index
;
var
text
=
this
.
container
.
firstChild
;
this
.
range
=
range
;
range
.
setStart
(
text
||
this
.
container
,
this
.
index
).
collapse
(
true
);
setTimeout
(
function
()
{
range
.
setStart
(
text
||
this
.
container
,
this
.
index
).
collapse
(
true
);
setTimeout
(
function
()
{
range
.
select
()
}
);
});
return
this
;
},
setTextShape
:
function
(
textShape
)
{
if
(
!
textShape
)
{
setTextShape
:
function
(
textShape
)
{
if
(
!
textShape
)
{
textShape
=
new
kity
.
Text
();
}
this
.
textShape
=
textShape
;
this
.
container
.
innerHTML
=
textShape
.
getContent
();
return
this
;
},
setTextShapeSize
:
function
(
size
)
{
this
.
textShape
.
setSize
(
size
);
setTextShapeSize
:
function
(
size
)
{
this
.
textShape
.
setSize
(
size
);
return
this
;
},
getTextShapeHeight
:
function
()
{
getTextShapeHeight
:
function
()
{
return
this
.
textShape
.
getRenderBox
().
height
;
},
appendTextShapeToPaper
:
function
(
paper
)
{
paper
.
addShape
(
this
.
textShape
);
appendTextShapeToPaper
:
function
(
paper
)
{
paper
.
addShape
(
this
.
textShape
);
return
this
;
},
setKityMinder
:
function
(
km
)
{
setKityMinder
:
function
(
km
)
{
this
.
km
=
km
;
return
this
;
},
setMinderNode
:
function
(
node
)
{
setMinderNode
:
function
(
node
)
{
this
.
minderNode
=
node
;
return
this
;
},
keyboardEvents
:
function
(
e
)
{
keyboardEvents
:
function
(
e
)
{
clearTimeout
(
this
.
timer
);
clearTimeout
(
this
.
timer
);
var
me
=
this
;
var
keyCode
=
e
.
originEvent
.
keyCode
;
switch
(
e
.
type
)
{
switch
(
e
.
type
)
{
case
'beforekeyup'
:
if
(
this
.
isTextEditStatus
()
)
{
switch
(
keyCode
)
{
if
(
this
.
isTextEditStatus
())
{
switch
(
keyCode
)
{
case
keymap
.
Enter
:
case
keymap
.
Tab
:
this
.
setTextEditStatus
(
false
);
this
.
setTextEditStatus
(
false
);
this
.
clear
();
e
.
stopPropagation
();
return
;
}
var
text
=
(
this
.
container
.
textContent
||
this
.
container
.
innerText
).
replace
(
/
\u
200b/g
,
''
);
var
text
=
(
this
.
container
.
textContent
||
this
.
container
.
innerText
).
replace
(
/
\u
200b/g
,
''
);
this
.
textShape
.
setContent
(
text
);
this
.
textShape
.
setContent
(
text
);
this
.
setContainerStyle
();
this
.
minderNode
.
setText
(
text
);
this
.
km
.
updateLayout
(
this
.
minderNode
);
this
.
minderNode
.
setText
(
text
);
this
.
km
.
updateLayout
(
this
.
minderNode
);
this
.
setBaseOffset
();
this
.
updateTextData
();
this
.
updateIndex
();
this
.
updateCursor
();
this
.
timer
=
setTimeout
(
function
()
{
this
.
timer
=
setTimeout
(
function
()
{
me
.
cursor
.
setShow
()
},
500
);
},
500
);
return
true
;
}
}
},
updateIndex
:
function
()
{
updateIndex
:
function
()
{
this
.
index
=
this
.
range
.
getStart
().
startOffset
;
},
updateTextData
:
function
()
{
updateTextData
:
function
()
{
this
.
textShape
.
textData
=
this
.
getTextOffsetData
();
},
setCursor
:
function
(
cursor
)
{
setCursor
:
function
(
cursor
)
{
this
.
cursor
=
cursor
;
return
this
;
},
updateCursor
:
function
()
{
updateCursor
:
function
()
{
this
.
cursor
.
setShowHold
();
if
(
this
.
index
==
this
.
textData
.
length
)
{
this
.
cursor
.
setPosition
(
{
x
:
this
.
textData
[
this
.
index
-
1
].
x
+
this
.
textData
[
this
.
index
-
1
].
width
,
y
:
this
.
textData
[
this
.
index
-
1
].
y
}
)
}
else
{
this
.
cursor
.
setPosition
(
this
.
textData
[
this
.
index
]
)
if
(
this
.
index
==
this
.
textData
.
length
)
{
this
.
cursor
.
setPosition
({
x
:
this
.
textData
[
this
.
index
-
1
].
x
+
this
.
textData
[
this
.
index
-
1
].
width
,
y
:
this
.
textData
[
this
.
index
-
1
].
y
})
}
else
{
this
.
cursor
.
setPosition
(
this
.
textData
[
this
.
index
]
)
}
return
this
;
},
setBaseOffset
:
function
()
{
setBaseOffset
:
function
()
{
var
nodeOffset
=
this
.
minderNode
.
getRenderContainer
().
getRenderBox
();
// var textOffset = this.textShape.getRenderBox();
// var textOffset = this.textShape.getRenderBox();
var
contRcOffset
=
this
.
minderNode
.
getContRc
().
getRenderBox
();
this
.
offset
=
{
x
:
nodeOffset
.
x
+
contRcOffset
.
x
,
y
:
nodeOffset
.
y
+
contRcOffset
.
y
x
:
nodeOffset
.
x
+
contRcOffset
.
x
,
y
:
nodeOffset
.
y
+
contRcOffset
.
y
};
return
this
;
},
setContainerStyle
:
function
()
{
setContainerStyle
:
function
()
{
var
textShapeBox
=
this
.
textShape
.
getRenderBox
();
this
.
container
.
style
.
cssText
=
";left:"
+
this
.
offset
.
x
+
'px;top:'
+
(
this
.
offset
.
y
+
textShapeBox
.
height
)
+
'px;width:'
+
textShapeBox
.
width
+
'px;height:'
+
textShapeBox
.
height
+
'px;'
;
this
.
container
.
style
.
cssText
=
";left:"
+
this
.
offset
.
x
+
'px;top:'
+
(
this
.
offset
.
y
+
textShapeBox
.
height
)
+
'px;width:'
+
textShapeBox
.
width
+
'px;height:'
+
textShapeBox
.
height
+
'px;'
;
return
this
;
},
getTextOffsetData
:
function
()
{
getTextOffsetData
:
function
()
{
var
text
=
this
.
textShape
.
getContent
();
this
.
textData
=
[];
for
(
var
i
=
0
,
l
=
text
.
length
;
i
<
l
;
i
++
)
{
var
box
=
this
.
textShape
.
getExtentOfChar
(
i
);
this
.
textData
.
push
(
{
x
:
box
.
x
+
this
.
offset
.
x
,
y
:
this
.
offset
.
y
,
width
:
box
.
width
,
height
:
box
.
height
}
)
for
(
var
i
=
0
,
l
=
text
.
length
;
i
<
l
;
i
++
)
{
var
box
=
this
.
textShape
.
getExtentOfChar
(
i
);
this
.
textData
.
push
({
x
:
box
.
x
+
this
.
offset
.
x
,
y
:
this
.
offset
.
y
,
width
:
box
.
width
,
height
:
box
.
height
})
}
return
this
;
},
setCurrentIndex
:
function
(
offset
)
{
setCurrentIndex
:
function
(
offset
)
{
var
me
=
this
;
this
.
getTextOffsetData
();
var
hadChanged
=
false
;
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
)
{
me
.
index
=
0
;
return
false
;
}
if
(
i
==
me
.
textData
.
length
-
1
&&
offset
.
x
>=
v
.
x
)
{
if
(
i
==
me
.
textData
.
length
-
1
&&
offset
.
x
>=
v
.
x
)
{
me
.
index
=
me
.
textData
.
length
;
return
false
;
}
if
(
offset
.
x
>=
v
.
x
&&
offset
.
x
<=
v
.
x
+
v
.
width
)
{
if
(
offset
.
x
-
v
.
x
>
v
.
width
/
2
)
{
if
(
offset
.
x
>=
v
.
x
&&
offset
.
x
<=
v
.
x
+
v
.
width
)
{
if
(
offset
.
x
-
v
.
x
>
v
.
width
/
2
)
{
me
.
index
=
i
+
1
;
}
else
{
}
else
{
me
.
index
=
i
}
hadChanged
=
true
;
return
false
;
}
}
);
});
return
this
;
},
setCursorHeight
:
function
()
{
this
.
cursor
.
setHeight
(
this
.
getTextShapeHeight
()
);
setCursorHeight
:
function
()
{
this
.
cursor
.
setHeight
(
this
.
getTextShapeHeight
()
);
return
this
;
}
}
);
\ No newline at end of file
});
\ No newline at end of file
src/module/font.js
View file @
158f30b6
...
...
@@ -39,6 +39,7 @@ KityMinder.registerModule( "fontmodule", function () {
utils
.
each
(
nodes
,
function
(
i
,
n
)
{
n
.
setData
(
'fontfamily'
,
family
);
n
.
getTextShape
().
setAttr
(
'font-family'
,
family
);
km
.
updateLayout
(
n
)
}
)
}
}
),
...
...
@@ -50,6 +51,7 @@ KityMinder.registerModule( "fontmodule", function () {
utils
.
each
(
nodes
,
function
(
i
,
n
)
{
n
.
setData
(
'fontsize'
,
size
);
n
.
getTextShape
().
setSize
(
size
);
km
.
updateLayout
(
n
)
}
)
}
}
)
...
...
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