Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
qq_14980201
ueditor
提交
8ca80b4c
U
ueditor
项目概览
qq_14980201
/
ueditor
与 Fork 源项目一致
从无法访问的项目Fork
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
ueditor
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
8ca80b4c
编写于
2月 17, 2013
作者:
C
campaign
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
by zhanyi
上级
1489cbb2
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
4 addition
and
126 deletion
+4
-126
_src/plugins/source.js
_src/plugins/source.js
+4
-126
未找到文件。
_src/plugins/source.js
浏览文件 @
8ca80b4c
...
...
@@ -5,128 +5,6 @@
///commandsName Source
///commandsTitle 查看源码
(
function
(){
function
SourceFormater
(
config
){
config
=
config
||
{};
this
.
indentChar
=
config
.
indentChar
||
'
'
;
this
.
breakChar
=
config
.
breakChar
||
'
\n
'
;
this
.
selfClosingEnd
=
config
.
selfClosingEnd
||
'
/>
'
;
}
var
unhtml1
=
function
(){
var
map
=
{
'
<
'
:
'
<
'
,
'
>
'
:
'
>
'
,
'
"
'
:
'
"
'
,
"
'
"
:
'
'
'
};
function
rep
(
m
){
return
map
[
m
];
}
return
function
(
str
)
{
str
=
str
+
''
;
return
str
?
str
.
replace
(
/
[
<>"'
]
/g
,
rep
)
:
''
;
};
}();
var
inline
=
utils
.
extend
({
a
:
1
,
A
:
1
},
dtd
.
$inline
,
true
);
function
printAttrs
(
attrs
){
var
buff
=
[];
for
(
var
k
in
attrs
)
{
buff
.
push
(
k
+
'
="
'
+
unhtml1
(
attrs
[
k
])
+
'
"
'
);
}
return
buff
.
join
(
'
'
);
}
SourceFormater
.
prototype
=
{
format
:
function
(
html
){
var
node
=
UE
.
serialize
.
parseHTML
(
html
);
this
.
buff
=
[];
this
.
indents
=
''
;
this
.
indenting
=
1
;
this
.
visitNode
(
node
);
return
this
.
buff
.
join
(
''
);
},
visitNode
:
function
(
node
){
if
(
node
.
type
==
'
fragment
'
)
{
this
.
visitChildren
(
node
.
children
);
}
else
if
(
node
.
type
==
'
element
'
)
{
var
selfClosing
=
dtd
.
$empty
[
node
.
tag
];
this
.
visitTag
(
node
.
tag
,
node
.
attributes
,
selfClosing
);
this
.
visitChildren
(
node
.
children
);
if
(
!
selfClosing
)
{
this
.
visitEndTag
(
node
.
tag
);
}
}
else
if
(
node
.
type
==
'
comment
'
)
{
this
.
visitComment
(
node
.
data
);
}
else
{
this
.
visitText
(
node
.
data
,
dtd
.
$notTransContent
[
node
.
parent
.
tag
]);
}
},
visitChildren
:
function
(
children
){
for
(
var
i
=
0
;
i
<
children
.
length
;
i
++
)
{
this
.
visitNode
(
children
[
i
]);
}
},
visitTag
:
function
(
tag
,
attrs
,
selfClosing
){
if
(
this
.
indenting
)
{
this
.
indent
();
}
else
if
(
!
inline
[
tag
])
{
// todo: 去掉a, 因为dtd的inline里面没有a
this
.
newline
();
this
.
indent
();
}
this
.
buff
.
push
(
'
<
'
,
tag
);
var
attrPart
=
printAttrs
(
attrs
);
if
(
attrPart
)
{
this
.
buff
.
push
(
'
'
,
attrPart
);
}
if
(
selfClosing
)
{
this
.
buff
.
push
(
this
.
selfClosingEnd
);
if
(
tag
==
'
br
'
)
{
this
.
newline
();
}
}
else
{
this
.
buff
.
push
(
'
>
'
);
this
.
indents
+=
this
.
indentChar
;
}
if
(
!
inline
[
tag
])
{
this
.
newline
();
}
},
indent
:
function
(){
this
.
buff
.
push
(
this
.
indents
);
this
.
indenting
=
0
;
},
newline
:
function
(){
this
.
buff
.
push
(
this
.
breakChar
);
this
.
indenting
=
1
;
},
visitEndTag
:
function
(
tag
){
this
.
indents
=
this
.
indents
.
slice
(
0
,
-
this
.
indentChar
.
length
);
if
(
this
.
indenting
)
{
this
.
indent
();
}
else
if
(
!
inline
[
tag
])
{
this
.
newline
();
this
.
indent
();
}
this
.
buff
.
push
(
'
</
'
,
tag
,
'
>
'
);
},
visitText
:
function
(
text
,
notTrans
){
if
(
this
.
indenting
)
{
this
.
indent
();
}
// if(!notTrans){
// text = text.replace(/ /g, ' ').replace(/[ ][ ]+/g, function (m){
// return new Array(m.length + 1).join(' ');
// }).replace(/(?:^ )|(?: $)/g, ' ');
// }
text
=
text
.
replace
(
/ /g
,
'
'
);
this
.
buff
.
push
(
text
);
},
visitComment
:
function
(
text
){
if
(
this
.
indenting
)
{
this
.
indent
();
}
this
.
buff
.
push
(
'
<!--
'
,
text
,
'
-->
'
);
}
};
var
sourceEditors
=
{
textarea
:
function
(
editor
,
holder
){
var
textarea
=
holder
.
ownerDocument
.
createElement
(
'
textarea
'
);
...
...
@@ -206,7 +84,6 @@
UE
.
plugins
[
'
source
'
]
=
function
(){
var
me
=
this
;
var
opt
=
this
.
options
;
var
formatter
=
new
SourceFormater
(
opt
.
source
);
var
sourceMode
=
false
;
var
sourceEditor
;
...
...
@@ -237,8 +114,9 @@
bakCssText
=
me
.
iframe
.
style
.
cssText
;
me
.
iframe
.
style
.
cssText
+=
'
position:absolute;left:-32768px;top:-32768px;
'
;
var
root
=
UE
.
htmlparser
(
me
.
getContent
());
var
content
=
formatter
.
format
(
me
.
hasContents
()
?
me
.
getContent
()
:
''
)
;
var
content
=
me
.
hasContents
()
?
root
.
toHtml
(
true
)
:
''
;
sourceEditor
=
createSourceEditor
(
me
.
iframe
.
parentNode
);
...
...
@@ -254,12 +132,12 @@
//重置getContent,源码模式下取值也能是最新的数据
me
.
getContent
=
function
(){
var
cont
=
sourceEditor
.
getContent
()
||
'
<p>
'
+
(
browser
.
ie
?
''
:
'
<br/>
'
)
+
'
</p>
'
;
return
cont
.
replace
(
/>
[
\n\r\t]
+
([
]{4})
+/g
,
'
>
'
).
replace
(
/
[\n\r\t]
+
([
]{4})
+</g
,
'
<
'
).
replace
(
/>
[\n\r\t]
+</g
,
'
><
'
);
return
cont
.
replace
(
/>
[
\n\r\t]
+/g
,
'
>
'
).
replace
(
/
[
\n\r\t]
+</g
,
'
<
'
).
replace
(
/>
[\n\r\t]
+</g
,
'
><
'
);
};
}
else
{
me
.
iframe
.
style
.
cssText
=
bakCssText
;
var
cont
=
sourceEditor
.
getContent
()
||
'
<p>
'
+
(
browser
.
ie
?
''
:
'
<br/>
'
)
+
'
</p>
'
;
cont
=
cont
.
replace
(
/>
[
\n\r\t]
+
([
]{4})
+/g
,
'
>
'
).
replace
(
/
[\n\r\t]
+
([
]{4})
+</g
,
'
<
'
).
replace
(
/>
[\n\r\t]
+</g
,
'
><
'
);
cont
=
cont
.
replace
(
/>
[
\n\r\t]
+/g
,
'
>
'
).
replace
(
/
[
\n\r\t]
+</g
,
'
<
'
).
replace
(
/>
[\n\r\t]
+</g
,
'
><
'
);
me
.
setContent
(
cont
);
sourceEditor
.
dispose
();
sourceEditor
=
null
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录