From a54f55bbacfc1ecf83cc5b022cadcc0d79d74611 Mon Sep 17 00:00:00 2001 From: yanglbme Date: Sat, 21 Nov 2020 01:34:46 +0000 Subject: [PATCH] style: prettify code --- src/assets/scripts/closebrackets.js | 28 ++++++++++++++-------------- src/assets/scripts/util.js | 5 ++--- 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/src/assets/scripts/closebrackets.js b/src/assets/scripts/closebrackets.js index 1434e64..88fc701 100644 --- a/src/assets/scripts/closebrackets.js +++ b/src/assets/scripts/closebrackets.js @@ -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; diff --git a/src/assets/scripts/util.js b/src/assets/scripts/util.js index 3d966ad..b3d13db 100644 --- a/src/assets/scripts/util.js +++ b/src/assets/scripts/util.js @@ -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");