mirror of
https://github.com/mindoc-org/mindoc.git
synced 2025-04-05 20:17:53 +08:00

* 使用cherryMarkdown替换editorMd * 支持历史&边栏 * 优化代码&支持html格式渲染为预览格式&保存主题配置 * 修复drawio异常 * 优化drawio异常改法 * 自定义提示面板主题颜色 * drawio增加样式,并且更新到最新版本 * 增加代码块复制功能&&修复drawio渲染图片过大&&drawio生成图片背景改为透明 * 恢复原有markdown编辑器,新增cherry markdown编辑器 * 修复复制功能异常 * 修复drawio偶尔无法编辑 --------- Co-authored-by: zhangsheng.93 <zhangsheng.93@bytedance.com>
82 lines
2.1 KiB
JavaScript
82 lines
2.1 KiB
JavaScript
/**
|
||
* Created by Alex on 2016/3/7.
|
||
*/
|
||
var hzpy = require("./hanziPinyin").hzpy;
|
||
var hzpyWithOutYin = require("./hanziPinyinWithoutYin").hzpy;
|
||
var _ = require("lodash");
|
||
|
||
function pinyin(word,splitStr) {
|
||
splitStr = splitStr === undefined ? ' ' : splitStr;
|
||
var str = '';
|
||
var s;
|
||
for (var i = 0; i < word.length; i++) {
|
||
if (hzpy.indexOf(word.charAt(i)) != -1 && word.charCodeAt(i) > 200) {
|
||
s = 1;
|
||
while (hzpy.charAt(hzpy.indexOf(word.charAt(i)) + s) != ",") {
|
||
str += hzpy.charAt(hzpy.indexOf(word.charAt(i)) + s);
|
||
s++;
|
||
}
|
||
str += splitStr;
|
||
}
|
||
else {
|
||
str += word.charAt(i);
|
||
}
|
||
}
|
||
return str;
|
||
}
|
||
|
||
//无声调的拼音
|
||
function pinyinWithOutYin(word,splitStr) {
|
||
splitStr = splitStr === undefined ? ' ' : splitStr;
|
||
var str = '';
|
||
var s;
|
||
for (var i = 0; i < word.length; i++) {
|
||
if (hzpyWithOutYin.indexOf(word.charAt(i)) != -1 && word.charCodeAt(i) > 200) {
|
||
s = 1;
|
||
while (hzpyWithOutYin.charAt(hzpyWithOutYin.indexOf(word.charAt(i)) + s) != ",") {
|
||
str += hzpyWithOutYin.charAt(hzpyWithOutYin.indexOf(word.charAt(i)) + s);
|
||
s++;
|
||
}
|
||
str +=splitStr;
|
||
}
|
||
else {
|
||
str += word.charAt(i);
|
||
}
|
||
}
|
||
|
||
return str;
|
||
}
|
||
|
||
function isChineseWord(word, modle) {
|
||
if (!modle) {
|
||
//modle为false是非严格中文!默认是严格中文
|
||
modle = true;
|
||
}
|
||
var str = '';
|
||
var isChinese = false;
|
||
for (var i = 0; i < word.length; i++) {
|
||
if (hzpy.indexOf(word.charAt(i)) != -1 && word.charCodeAt(i) > 200) {
|
||
isChinese = true;
|
||
}
|
||
else {
|
||
if (modle) {
|
||
return false;
|
||
}
|
||
}
|
||
}
|
||
return isChinese;
|
||
}
|
||
|
||
function sort(array, key) {
|
||
return _.sortBy(array, [function (o) {
|
||
return pinyinWithOutYin(o[key],"");
|
||
}]);
|
||
}
|
||
|
||
module.exports = {
|
||
pinyin: pinyin,
|
||
pinyinWithOutYin: pinyinWithOutYin,
|
||
isChineseWord: isChineseWord,
|
||
sort: sort
|
||
}
|