Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
易企天创
zui
提交
1feaac6b
Z
zui
项目概览
易企天创
/
zui
10 个月 前同步成功
通知
6
Star
0
Fork
1
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
37
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Z
zui
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
37
Issue
37
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
1feaac6b
编写于
4月 30, 2019
作者:
C
Catouse
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
* refactor kindeditor: finish task #014, task #013, task #012.
上级
a5a71946
变更
5
展开全部
隐藏空白更改
内联
并排
Showing
5 changed file
with
1036 addition
and
763 deletion
+1036
-763
src/js/kindeditor/kindeditor.js
src/js/kindeditor/kindeditor.js
+0
-763
src/js/kindeditor/plugins/advance-table.js
src/js/kindeditor/plugins/advance-table.js
+762
-0
src/js/kindeditor/plugins/paste-image.js
src/js/kindeditor/plugins/paste-image.js
+168
-0
src/js/kindeditor/plugins/placeholder.js
src/js/kindeditor/plugins/placeholder.js
+53
-0
src/js/kindeditor/plugins/zui.js
src/js/kindeditor/plugins/zui.js
+53
-0
未找到文件。
src/js/kindeditor/kindeditor.js
浏览文件 @
1feaac6b
此差异已折叠。
点击以展开。
src/js/kindeditor/plugins/advance-table.js
0 → 100644
浏览文件 @
1feaac6b
此差异已折叠。
点击以展开。
src/js/kindeditor/plugins/paste-image.js
0 → 100644
浏览文件 @
1feaac6b
/* ========================================================================
* ZUI: Kindeditor plugin - paste-image
* http://zui.sexy
* ========================================================================
* Copyright (c) 2019-2019 cnezsoft.com; Licensed MIT
* ======================================================================== */
KindEditor
.
plugin
(
'
pasteimage
'
,
function
(
K
)
{
var
self
=
this
;
var
allLangs
=
{
zh_cn
:
{
notSupportMsg
:
'
您的浏览器不支持粘贴图片!
'
,
placeholder
:
'
可以在编辑器直接贴图。
'
,
failMsg
:
'
贴图失败,请稍后重试。
'
,
uploadingHint
:
'
正在上传图片,请稍后...
'
,
},
zh_tw
:
{
notSupportMsg
:
'
您的瀏覽器不支持粘貼圖片!
'
,
placeholder
:
'
可以在編輯器直接貼圖。
'
,
failMsg
:
'
貼圖失敗,請稍後重試。
'
,
uploadingHint
:
'
正在上傳圖片,請稍後...
'
,
},
en
:
{
notSupportMsg
:
'
Image is not allowed to paste in your browser!
'
,
placeholder
:
'
Paste images here.
'
,
failMsg
:
'
Pasting image failed. Try again later.
'
,
uploadingHint
:
'
Uploading...
'
,
}
};
var
lang
=
$
.
extend
({},
allLangs
[(
$
.
clientLang
||
$
.
zui
.
clientLang
)()]);
self
.
afterCreate
(
function
()
{
var
edit
=
self
.
edit
;
var
doc
=
edit
.
doc
;
var
uuid
=
self
.
uuid
;
var
options
=
self
.
options
.
pasteImage
;
if
(
!
options
)
{
return
;
}
if
(
typeof
options
===
'
string
'
)
{
options
=
{
url
:
options
};
}
$
.
extend
({
placeholder
:
placeholder
},
options
);
if
(
!
K
.
WEBKIT
&&
!
K
.
GECKO
)
{
$
(
doc
.
body
).
on
(
'
keyup.ke
'
+
uuid
,
function
(
ev
)
{
if
(
ev
.
keyCode
==
86
&&
ev
.
ctrlKey
)
alert
(
lang
.
notSupportMsg
);
});
}
if
(
self
.
setPlaceholder
)
{
var
placeholder
=
options
.
placeholder
;
if
(
placeholder
===
true
)
placeholder
=
lang
.
placeholder
;
if
(
placeholder
)
{
var
oldPlaceholder
=
self
.
getPlaceholder
();
if
(
!
oldPlaceholder
)
oldPlaceholder
=
placeholder
;
else
if
(
oldPlaceholder
.
indexOf
(
placeholder
)
<
0
)
placeholder
=
oldPlaceholder
+
'
\n
'
+
placeholder
;
}
}
var
pasteBegin
=
function
()
{
// if ($.enableForm) {
// $.enableForm(false, 0, 1);
// $('body').one('click.ke' + uuid, function(){$.enableForm(true);});
// }
if
(
options
.
beforePaste
)
{
options
.
beforePaste
();
}
var
imageLoadingEle
=
'
<div class="image-loading-ele small" style="padding: 5px; background: #FFF3E0; width: 300px; border-radius: 2px; border: 1px solid #FF9800; color: #ff5d5d; margin: 10px 0;"><i class="icon icon-spin icon-spinner-indicator muted"></i>
'
+
lang
.
uploadingHint
+
'
</div>
'
;
edit
.
cmd
.
inserthtml
(
imageLoadingEle
);
self
.
readonly
(
true
);
};
var
pasteEnd
=
function
(
error
)
{
if
(
error
)
{
if
(
options
.
onError
)
{
options
.
onError
(
error
);
}
else
{
if
(
error
===
true
)
error
=
lang
.
failMsg
;
if
(
$
.
zui
&&
$
.
zui
.
messager
)
{
$
.
zui
.
messager
.
danger
(
error
,
{
placement
:
'
center
'
});
}
}
}
// if ($.enableForm) {
// $.enableForm(true, 0, 1);
// }
// $('body').off('.ke' + uuid);
if
(
options
.
afterPaste
)
{
options
.
afterPaste
();
}
$
(
doc
.
body
).
find
(
'
.image-loading-ele
'
).
remove
();
self
.
readonly
(
false
);
};
var
pasteUrl
=
options
.
postUrl
;
$
(
doc
.
body
).
on
(
'
paste
'
,
function
(
ev
)
{
if
(
K
.
WEBKIT
)
{
/* Paste in chrome.*/
/* Code reference from http://www.foliotek.com/devblog/copy-images-from-clipboard-in-javascript/. */
var
original
=
ev
.
originalEvent
;
var
clipboardItems
=
original
.
clipboardData
&&
original
.
clipboardData
.
items
;
var
clipboardItem
=
null
;
if
(
clipboardItems
)
{
var
IMAGE_MIME_REGEX
=
/^image
\/(
p
?
jpeg|gif|png
)
$/i
;
for
(
var
i
=
0
;
i
<
clipboardItems
.
length
;
i
++
)
{
if
(
IMAGE_MIME_REGEX
.
test
(
clipboardItems
[
i
].
type
))
{
clipboardItem
=
clipboardItems
[
i
];
break
;
}
}
}
var
file
=
clipboardItem
&&
clipboardItem
.
getAsFile
();
if
(
!
file
)
return
;
original
.
preventDefault
();
pasteBegin
();
var
reader
=
new
FileReader
();
reader
.
onload
=
function
(
evt
)
{
var
result
=
evt
.
target
.
result
;
// var arr = result.split(",");
// var data = arr[1]; // raw base64
// var contentType = arr[0].split(";")[0].split(":")[1];
html
=
'
<img src="
'
+
result
+
'
" alt="" />
'
;
$
.
post
(
pasteUrl
,
{
editor
:
html
},
function
(
data
)
{
if
(
data
)
{
edit
.
cmd
.
inserthtml
(
data
);
}
else
{
edit
.
cmd
.
inserthtml
(
html
);
}
pasteEnd
();
}).
error
(
function
()
{
pasteEnd
(
true
);
});
};
reader
.
readAsDataURL
(
file
);
}
else
{
/* Paste in firefox and other browsers. */
setTimeout
(
function
()
{
var
html
=
K
(
doc
.
body
).
html
();
if
(
html
.
search
(
/<img src="data:.+;base64,/
)
>
-
1
)
{
pasteBegin
();
$
.
post
(
pasteUrl
,
{
editor
:
html
},
function
(
data
)
{
if
(
data
.
indexOf
(
'
<img
'
)
===
0
)
data
=
'
<p>
'
+
data
+
'
</p>
'
;
edit
.
html
(
data
);
pasteEnd
();
}).
error
(
function
()
{
pasteEnd
(
true
);
});
}
},
80
);
}
});
self
.
beforeRemove
(
function
()
{
$
(
doc
.
body
).
off
(
'
.ke
'
+
uuid
);
});
});
});
\ No newline at end of file
src/js/kindeditor/plugins/placeholder.js
0 → 100644
浏览文件 @
1feaac6b
/* ========================================================================
* ZUI: Kindeditor plugin - placeholder
* http://zui.sexy
* ========================================================================
* Copyright (c) 2019-2019 cnezsoft.com; Licensed MIT
* ======================================================================== */
KindEditor
.
EditorClass
.
prototype
.
setPlaceholder
=
function
(
placeholder
,
asHtml
)
{
var
self
=
this
;
var
options
=
self
.
options
;
var
edit
=
self
.
edit
;
var
$doc
=
$
(
edit
.
doc
);
var
$placeholder
=
$doc
.
find
(
'
.kindeditor-ph
'
);
if
(
!
$placeholder
.
length
)
{
$placeholder
=
$
(
'
<div class="kindeditor-ph" style="width:100%; color:#888; padding: 8px; background:none; position:absolute;z-index:10;top:0;border:0;overflow:auto;resize:none; pointer-events:none; white-space: pre-wrap;"></div>
'
);
if
(
options
.
placeholderStyle
)
{
$placeholder
.
css
(
options
.
placeholderStyle
);
}
$doc
.
find
(
'
body
'
).
after
(
$placeholder
);
}
if
(
$
.
trim
(
self
.
html
())
!==
''
)
{
$placeholder
.
hide
();
}
$placeholder
[
asHtml
?
'
html
'
:
'
text
'
](
placeholder
);
};
KindEditor
.
EditorClass
.
prototype
.
getPlaceholder
=
function
(
asHtml
)
{
return
$
(
this
.
edit
.
doc
).
find
(
'
.kindeditor-ph
'
)[
asHtml
?
'
html
'
:
'
text
'
]();
};
KindEditor
.
plugin
(
'
placeholder
'
,
function
(
K
)
{
var
self
=
this
;
self
.
afterBlur
(
function
()
{
if
(
$
.
trim
(
self
.
html
())
===
''
)
{
$
(
self
.
edit
.
doc
).
find
(
'
.kindeditor-ph
'
).
show
();
}
});
self
.
afterFocus
(
function
()
{
$
(
self
.
edit
.
doc
).
find
(
'
.kindeditor-ph
'
).
hide
();
});
self
.
afterCreate
(
function
()
{
var
options
=
self
.
options
;
if
(
options
.
placeholderHtml
)
{
self
.
setPlaceholder
(
options
.
placeholderHtml
,
true
);
}
else
if
(
options
.
placeholder
)
{
self
.
setPlaceholder
(
options
.
placeholder
);
}
console
.
log
(
'
afterSetHtml
'
);
});
});
\ No newline at end of file
src/js/kindeditor/plugins/zui.js
0 → 100644
浏览文件 @
1feaac6b
/* ========================================================================
* ZUI: Kindeditor plugin - zui
* http://zui.sexy
* ========================================================================
* Copyright (c) 2019-2019 cnezsoft.com; Licensed MIT
* ======================================================================== */
$
.
each
([
'
afterBlur
'
,
'
afterFocus
'
,
'
afterChange
'
,
'
afterTab
'
],
function
(
_index
,
name
)
{
KindEditor
.
EditorClass
.
prototype
[
name
]
=
function
(
fn
)
{
return
this
.
handler
(
name
,
fn
);
};
});
KindEditor
.
plugin
(
'
zui
'
,
function
(
K
)
{
var
self
=
this
;
var
options
=
self
.
options
;
self
.
uuid
=
$
.
zui
.
uuid
();
var
spellcheck
=
options
.
spellcheck
;
if
(
spellcheck
!==
undefined
)
{
self
.
edit
.
doc
.
documentElement
.
setAttribute
(
'
spellcheck
'
,
spellcheck
);
}
self
.
afterBlur
(
function
()
{
if
(
options
.
syncAfterBlur
)
{
self
.
sync
();
}
self
.
container
.
removeClass
(
'
focus
'
);
});
self
.
afterFocus
(
function
()
{
self
.
container
.
addClass
(
'
focus
'
);
});
self
.
afterChange
(
function
()
{
self
.
edit
.
srcElement
.
change
().
hide
();
});
self
.
afterCreate
(
function
()
{
$
(
self
.
edit
.
srcElement
[
0
]).
data
(
'
keditor
'
,
self
);
});
var
nextFormControl
=
'
input:not([type="hidden"]), textarea:not(.ke-edit-textarea), button[type="submit"], select
'
;
self
.
afterTab
(
function
()
{
var
$editor
=
$
(
self
.
edit
.
srcElement
[
0
]);
var
$next
=
$editor
.
next
(
nextFormControl
);
if
(
!
$next
.
length
)
$next
=
$editor
.
parent
().
next
().
find
(
nextFormControl
);
if
(
!
$next
.
length
)
$next
=
$editor
.
parent
().
parent
().
next
().
find
(
nextFormControl
);
$next
=
$next
.
first
();
var
keditor
=
$next
.
data
(
'
keditor
'
);
if
(
keditor
)
keditor
.
focus
();
else
$next
.
focus
();
});
});
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录