Skip to content

Commit

Permalink
feat: reset style only (doocs#108)
Browse files Browse the repository at this point in the history
* reset style only
* close doocs#107
  • Loading branch information
yanglbme authored Nov 29, 2021
1 parent 449617f commit bc4a629
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 16 deletions.
10 changes: 4 additions & 6 deletions src/components/CodemirrorEditor/header.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@
>
<i class="el-icon-document" size="medium" @click="$emit('export')"></i>
</el-tooltip>
<!-- 页面重置 -->
<!-- 样式重置 -->
<el-tooltip
class="header__item"
:effect="effect"
content="重置页面"
content="重置样式"
placement="bottom-start"
>
<i
Expand Down Expand Up @@ -316,11 +316,10 @@ export default {
this.setCssEditorValue(DEFAULT_CSS_CONTENT);
}
},
// 重置页面
// 重置样式
confirmReset() {
localStorage.clear();
this.clearEditorToDefault();
this.editor.focus();
this.cssEditor.setValue(DEFAULT_CSS_CONTENT);
this.citeStatus = false;
this.statusChanged(false);
this.fontChanged(this.config.builtinFonts[0].value);
Expand All @@ -337,7 +336,6 @@ export default {
this.editor.focus();
},
...mapMutations([
"clearEditorToDefault",
"setCurrentColor",
"setCiteStatus",
"themeChanged",
Expand Down
2 changes: 1 addition & 1 deletion src/components/CodemirrorEditor/resetDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
:visible="showResetConfirm"
@close="$emit('close')"
>
<div class="text">此操作将丢失本地缓存的文本和自定义样式,是否继续?</div>
<div class="text">此操作将丢失本地自定义样式,是否继续?</div>
<div slot="footer" class="dialog-footer">
<el-button :type="btnType" plain @click="$emit('close')">取 消</el-button>
<el-button :type="btnType" @click="$emit('confirm')" plain
Expand Down
4 changes: 2 additions & 2 deletions src/components/CodemirrorEditor/rightClickMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ export default {
key: "insertTable",
},
{
text: "页面重置",
key: "pageReset",
text: "恢复默认样式",
key: "resetStyle",
},
],
[
Expand Down
2 changes: 1 addition & 1 deletion src/pages/index/view/CodemirrorEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ export default {
},
onMenuEvent(type, info = {}) {
switch (type) {
case "pageReset":
case "resetStyle":
this.$refs.header.showResetConfirm = true;
break;
case "insertPic":
Expand Down
6 changes: 0 additions & 6 deletions src/store/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,12 +154,6 @@ const mutations = {
}
state.output = output;
},
clearEditorToDefault(state) {
const doc = formatDoc(DEFAULT_CONTENT);

state.editor.setValue(doc);
state.cssEditor.setValue(DEFAULT_CSS_CONTENT);
},
};

export default new Vuex.Store({
Expand Down

0 comments on commit bc4a629

Please sign in to comment.