mirror of
https://github.com/doocs/md.git
synced 2024-11-28 13:36:32 +08:00
style: prettify code
This commit is contained in:
parent
aee49b2d32
commit
a54f55bbac
@ -11,21 +11,21 @@ import CodeMirror from "codemirror/lib/codemirror";
|
||||
|
||||
var Pos = CodeMirror.Pos;
|
||||
|
||||
CodeMirror.defineOption("autoCloseBrackets", false, function (
|
||||
cm,
|
||||
val,
|
||||
old
|
||||
) {
|
||||
if (old && old != CodeMirror.Init) {
|
||||
cm.removeKeyMap(keyMap);
|
||||
cm.state.closeBrackets = null;
|
||||
CodeMirror.defineOption(
|
||||
"autoCloseBrackets",
|
||||
false,
|
||||
function (cm, val, old) {
|
||||
if (old && old != CodeMirror.Init) {
|
||||
cm.removeKeyMap(keyMap);
|
||||
cm.state.closeBrackets = null;
|
||||
}
|
||||
if (val) {
|
||||
ensureBound(getOption(val, "pairs"));
|
||||
cm.state.closeBrackets = val;
|
||||
cm.addKeyMap(keyMap);
|
||||
}
|
||||
}
|
||||
if (val) {
|
||||
ensureBound(getOption(val, "pairs"));
|
||||
cm.state.closeBrackets = val;
|
||||
cm.addKeyMap(keyMap);
|
||||
}
|
||||
});
|
||||
);
|
||||
|
||||
function getOption(conf, name) {
|
||||
if (name == "pairs" && typeof conf == "string") return conf;
|
||||
|
@ -190,7 +190,7 @@ export function saveEditorContent(editor, name) {
|
||||
|
||||
/**
|
||||
* 格式化文档
|
||||
* @param {文档内容} content
|
||||
* @param {文档内容} content
|
||||
*/
|
||||
export function formatDoc(content) {
|
||||
const doc = prettier.format(content, {
|
||||
@ -200,7 +200,6 @@ export function formatDoc(content) {
|
||||
return doc;
|
||||
}
|
||||
|
||||
|
||||
export function fixCodeWhiteSpace(value = "pre") {
|
||||
const preDomList = document.getElementsByClassName("code__pre");
|
||||
if (preDomList.length > 0) {
|
||||
@ -212,7 +211,7 @@ export function fixCodeWhiteSpace(value = "pre") {
|
||||
|
||||
/**
|
||||
* 下载原始 Markdown 文档
|
||||
* @param {文档内容} doc
|
||||
* @param {文档内容} doc
|
||||
*/
|
||||
export function downLoadMD(doc) {
|
||||
let downLink = document.createElement("a");
|
||||
|
Loading…
Reference in New Issue
Block a user