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
564bb5a4
Commit
564bb5a4
authored
Sep 09, 2014
by
campaign
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加换行机制
parent
37352939
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
31 additions
and
16 deletions
+31
-16
utils.js
src/core/utils.js
+5
-0
editor.js
src/module/editor.js
+7
-4
editor.keyboard.js
src/module/editor.keyboard.js
+13
-8
editor.range.js
src/module/editor.range.js
+3
-2
editor.receiver.js
src/module/editor.receiver.js
+3
-2
No files found.
src/core/utils.js
View file @
564bb5a4
...
...
@@ -281,7 +281,12 @@ var utils = Utils = KityMinder.Utils = {
utils
.
each
(
data
,
function
(
i
,
arr
){
if
(
initIndex
+
arr
.
length
>=
index
){
if
(
index
-
initIndex
==
arr
.
length
){
if
(
arr
.
length
==
1
&&
arr
[
0
].
width
===
0
){
initIndex
++
;
return
;
}
result
=
{
x
:
arr
[
arr
.
length
-
1
].
x
+
arr
[
arr
.
length
-
1
].
width
,
y
:
arr
[
arr
.
length
-
1
].
y
...
...
src/module/editor.js
View file @
564bb5a4
...
...
@@ -210,12 +210,15 @@ KityMinder.registerModule('TextEditModule', function() {
var
node
=
e
.
getTargetNode
();
e
.
stopPropagationImmediately
();
if
(
node
){
var
offset
=
e
.
getPosition
(
node
.
getRenderContainer
());
receiver
.
updateSelectionByMousePosition
(
offset
)
.
updateSelection
(
offset
)
.
updateContainerRangeBySel
();
}
}
else
if
(
mouseDownStatus
&&
!
selectionReadyShow
){
//第一次点中,第二次再次点中进行拖拽
...
...
src/module/editor.keyboard.js
View file @
564bb5a4
...
...
@@ -309,6 +309,11 @@ Minder.keyboarder = kity.createClass('keyboarder', function(){
},
//处理软回车操作
_handlerEnterkey
:
function
(){
function
removeTmpTextNode
(
node
){
if
(
node
&&
node
.
nodeType
==
3
&&
node
.
nodeValue
.
length
===
0
){
node
.
parentNode
.
removeChild
(
node
);
}
}
var
rng
=
this
.
range
;
var
br
=
document
.
createElement
(
'br'
);
var
me
=
this
;
...
...
@@ -316,18 +321,18 @@ Minder.keyboarder = kity.createClass('keyboarder', function(){
rng
.
deleteContents
();
}
rng
.
insertNode
(
br
);
removeTmpTextNode
(
br
.
previousSibling
);
removeTmpTextNode
(
br
.
nextSibling
);
rng
.
setStartAfter
(
br
);
rng
.
collapse
(
true
);
var
start
=
rng
.
startContainer
.
childNodes
[
rng
.
startOffset
];
if
(
start
&&
start
.
nodeType
==
3
&&
start
.
nodeValue
.
length
===
0
){
start
.
parentNode
.
removeChild
(
start
);
if
(
!
rng
.
startContainer
.
childNodes
[
rng
.
startOffset
]){
if
(
!
start
){
br
=
br
.
cloneNode
(
false
);
rng
.
startContainer
.
appendChild
(
br
);
rng
.
setStartBefore
(
br
);
rng
.
collapse
(
true
);
}
}
rng
.
select
();
me
.
_setTextToContainer
(
keymap
.
Enter
);
...
...
src/module/editor.range.js
View file @
564bb5a4
...
...
@@ -28,13 +28,13 @@ Minder.Range = kity.createClass('Range',function(){
var
rOffset
=
0
,
cont
=
rng
.
container
;
utils
.
each
(
cont
.
childNodes
,
function
(
index
,
node
){
if
(
node
.
nodeType
==
1
){
rOffset
++
;
if
(
rOffset
==
offset
){
rng
[
'set'
+
dir
](
cont
,
index
);
return
false
;
}
rOffset
++
;
return
;
}
...
...
@@ -65,6 +65,7 @@ Minder.Range = kity.createClass('Range',function(){
return
this
.
_updateBoundary
();
},
select
:
function
(){
var
start
=
this
.
nativeRange
.
startContainer
;
if
(
start
.
nodeType
==
1
&&
start
.
childNodes
.
length
===
0
){
var
char
=
document
.
createTextNode
(
'
\
u200b'
);
...
...
src/module/editor.receiver.js
View file @
564bb5a4
...
...
@@ -194,8 +194,8 @@ Minder.Receiver = kity.createClass('Receiver', {
return
false
;
}
if
(
i
==
arr
.
length
-
1
&&
offset
.
x
>=
v
.
x
)
{
me
.
index
+=
arr
.
length
;
me
.
index
+=
(
arr
.
length
==
1
&&
arr
[
0
].
width
===
0
?
0
:
arr
.
length
);
return
false
;
}
});
...
...
@@ -245,7 +245,8 @@ Minder.Receiver = kity.createClass('Receiver', {
return
false
;
}
if
(
i
==
arr
.
length
-
1
&&
offset
.
x
>=
v
.
x
)
{
result
+=
arr
.
length
;
result
+=
(
arr
.
length
==
1
&&
arr
[
0
].
width
===
0
?
0
:
arr
.
length
);
return
false
;
}
...
...
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