Skip to content

Commit

Permalink
feat(editor): 更新前进行对比
Browse files Browse the repository at this point in the history
  • Loading branch information
ZvonimirSun committed Dec 19, 2023
1 parent ffebd57 commit 200caa3
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/components/editor/editor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,20 @@ function onChange (update: ViewUpdate) {
function formatBtn () {
const val = props.plugin.formatter(cm.state.doc.toString())
cm.dispatch({
changes: { from: 0, to: cm.state.doc.length, insert: val }
})
if (val && val !== cm.state.doc.toString()) {
cm.dispatch({
changes: { from: 0, to: cm.state.doc.length, insert: val }
})
}
}
function compactBtn () {
const val = props.plugin.compactor(cm.state.doc.toString())
cm.dispatch({
changes: { from: 0, to: cm.state.doc.length, insert: val }
})
if (val && val !== cm.state.doc.toString()) {
cm.dispatch({
changes: { from: 0, to: cm.state.doc.length, insert: val }
})
}
}
function undoBtn () {
Expand Down

0 comments on commit 200caa3

Please sign in to comment.