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
27e48555
Commit
27e48555
authored
Jan 04, 2015
by
techird
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
文本增强支持
parent
13691ec4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
12 deletions
+33
-12
text.js
src/module/text.js
+33
-12
No files found.
src/module/text.js
View file @
27e48555
...
@@ -22,17 +22,17 @@ define(function(require, exports, module) {
...
@@ -22,17 +22,17 @@ define(function(require, exports, module) {
update
:
function
(
textGroup
,
node
)
{
update
:
function
(
textGroup
,
node
)
{
function
s
(
name
)
{
function
getDataOrStyle
(
name
)
{
return
node
.
getData
(
name
)
||
node
.
getStyle
(
name
);
return
node
.
getData
(
name
)
||
node
.
getStyle
(
name
);
}
}
var
nodeText
=
node
.
getText
()
||
''
;
var
nodeText
=
node
.
getText
();
var
textArr
=
nodeText
.
split
(
'
\
n'
)
;
var
textArr
=
nodeText
?
nodeText
.
split
(
'
\
n'
)
:
[
' '
]
;
var
lineHeight
=
node
.
getStyle
(
'line-height'
);
var
lineHeight
=
node
.
getStyle
(
'line-height'
);
var
fontSize
=
s
(
'font-size'
);
var
fontSize
=
getDataOrStyle
(
'font-size'
);
var
fontFamily
=
s
(
'font-family'
)
||
'default'
;
var
fontFamily
=
getDataOrStyle
(
'font-family'
)
||
'default'
;
var
height
=
(
lineHeight
*
fontSize
)
*
textArr
.
length
-
(
lineHeight
-
1
)
*
fontSize
;
var
height
=
(
lineHeight
*
fontSize
)
*
textArr
.
length
-
(
lineHeight
-
1
)
*
fontSize
;
var
yStart
=
-
height
/
2
;
var
yStart
=
-
height
/
2
;
...
@@ -58,8 +58,8 @@ define(function(require, exports, module) {
...
@@ -58,8 +58,8 @@ define(function(require, exports, module) {
textGroup
.
removeItem
(
i
);
textGroup
.
removeItem
(
i
);
}
}
}
else
if
(
textLength
>
textGroupLength
)
{
}
else
if
(
textLength
>
textGroupLength
)
{
var
leng
th
=
textLength
-
textGroupLength
;
var
grow
th
=
textLength
-
textGroupLength
;
for
(
i
=
0
;
i
<
length
;
i
++
)
{
while
(
growth
--
)
{
textShape
=
new
kity
.
Text
()
textShape
=
new
kity
.
Text
()
.
setAttr
(
'text-rendering'
,
'inherit'
);
.
setAttr
(
'text-rendering'
,
'inherit'
);
if
(
kity
.
Browser
.
ie
)
{
if
(
kity
.
Browser
.
ie
)
{
...
@@ -71,16 +71,15 @@ define(function(require, exports, module) {
...
@@ -71,16 +71,15 @@ define(function(require, exports, module) {
}
}
}
}
for
(
i
=
0
,
text
,
textShape
;
for
(
i
=
0
,
text
,
textShape
;
(
text
=
textArr
[
i
],
textShape
=
textGroup
.
getItem
(
i
));
i
++
)
{
(
text
=
textArr
[
i
],
textShape
=
textGroup
.
getItem
(
i
));
i
++
)
{
textShape
.
setContent
(
text
);
textShape
.
node
.
innerHTML
=
text
.
replace
(
'<'
,
'<'
).
replace
(
'>'
,
'>'
);
}
}
this
.
setTextStyle
(
node
,
textGroup
);
this
.
setTextStyle
(
node
,
textGroup
);
var
textHash
=
node
.
getText
()
+
var
textHash
=
node
.
getText
()
+
[
s
(
'font-size'
),
s
(
'font-name'
),
s
(
'font-weight'
),
s
(
'font-style'
)]
.
join
(
'/'
);
[
'font-size'
,
'font-name'
,
'font-weight'
,
'font-style'
].
map
(
getDataOrStyle
)
.
join
(
'/'
);
if
(
node
.
_currentTextHash
==
textHash
&&
node
.
_currentTextGroupBox
)
return
node
.
_currentTextGroupBox
;
if
(
node
.
_currentTextHash
==
textHash
&&
node
.
_currentTextGroupBox
)
return
node
.
_currentTextGroupBox
;
...
@@ -91,8 +90,8 @@ define(function(require, exports, module) {
...
@@ -91,8 +90,8 @@ define(function(require, exports, module) {
var
y
=
yStart
+
i
*
fontSize
*
lineHeight
;
var
y
=
yStart
+
i
*
fontSize
*
lineHeight
;
textShape
.
setY
(
y
);
textShape
.
setY
(
y
);
var
bbox
=
textShape
.
getBoundaryBox
();
rBox
=
rBox
.
merge
(
new
kity
.
Box
(
0
,
y
,
textShape
.
getBoundaryBox
()
.
width
||
1
,
fontSize
));
rBox
=
rBox
.
merge
(
new
kity
.
Box
(
0
,
y
,
bbox
.
height
&&
bbox
.
width
||
1
,
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
));
...
@@ -111,6 +110,25 @@ define(function(require, exports, module) {
...
@@ -111,6 +110,25 @@ define(function(require, exports, module) {
}
}
});
});
var
TextCommand
=
kity
.
createClass
({
base
:
Command
,
execute
:
function
(
minder
,
text
)
{
var
node
=
minder
.
getSelectedNode
();
if
(
node
)
{
node
.
setText
(
text
);
node
.
render
();
minder
.
layout
();
}
},
queryState
:
function
(
minder
)
{
return
minder
.
getSelectedNodes
().
length
==
1
?
0
:
-
1
;
},
queryValue
:
function
(
minder
)
{
var
node
=
minder
.
getSelectedNode
();
return
node
?
node
.
getText
()
:
null
;
}
});
utils
.
extend
(
TextRenderer
,
{
utils
.
extend
(
TextRenderer
,
{
_styleHooks
:
[],
_styleHooks
:
[],
...
@@ -126,6 +144,9 @@ define(function(require, exports, module) {
...
@@ -126,6 +144,9 @@ define(function(require, exports, module) {
});
});
Module
.
register
(
'text'
,
{
Module
.
register
(
'text'
,
{
'commands'
:
{
'text'
:
TextCommand
},
'renderers'
:
{
'renderers'
:
{
center
:
TextRenderer
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