mirror of
https://github.com/doocs/md.git
synced 2024-11-24 19:10:34 +08:00
bug修复
This commit is contained in:
parent
fe64205913
commit
b90d9ff59b
@ -73,7 +73,8 @@
|
|||||||
import {
|
import {
|
||||||
setColorWithCustomTemplate,
|
setColorWithCustomTemplate,
|
||||||
setFontSize,
|
setFontSize,
|
||||||
isImageIllegal
|
isImageIllegal,
|
||||||
|
fixCodeWhiteSpace
|
||||||
} from '../../scripts/util'
|
} from '../../scripts/util'
|
||||||
import fileApi from '../../api/file';
|
import fileApi from '../../api/file';
|
||||||
import {
|
import {
|
||||||
@ -173,20 +174,22 @@ export default {
|
|||||||
copy() {
|
copy() {
|
||||||
this.$emit('startCopy');
|
this.$emit('startCopy');
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
solveWeChatImage()
|
solveWeChatImage();
|
||||||
this.setOutput(solveHtml())
|
fixCodeWhiteSpace();
|
||||||
let clipboardDiv = document.getElementById('output')
|
this.setOutput(solveHtml());
|
||||||
|
let clipboardDiv = document.getElementById('output');
|
||||||
|
|
||||||
clipboardDiv.focus()
|
clipboardDiv.focus();
|
||||||
window.getSelection().removeAllRanges()
|
window.getSelection().removeAllRanges();
|
||||||
let range = document.createRange()
|
let range = document.createRange();
|
||||||
|
|
||||||
range.setStartBefore(clipboardDiv.firstChild)
|
range.setStartBefore(clipboardDiv.firstChild);
|
||||||
range.setEndAfter(clipboardDiv.lastChild)
|
range.setEndAfter(clipboardDiv.lastChild);
|
||||||
window.getSelection().addRange(range)
|
window.getSelection().addRange(range);
|
||||||
document.execCommand('copy')
|
document.execCommand('copy');
|
||||||
range.setStartBefore(clipboardDiv.firstChild)
|
range.setStartBefore(clipboardDiv.firstChild);
|
||||||
range.setEndAfter(clipboardDiv.firstChild)
|
range.setEndAfter(clipboardDiv.firstChild);
|
||||||
|
fixCodeWhiteSpace('normal');
|
||||||
// 输出提示
|
// 输出提示
|
||||||
this.$notify({
|
this.$notify({
|
||||||
showClose: true,
|
showClose: true,
|
||||||
@ -194,7 +197,7 @@ export default {
|
|||||||
offset: 80,
|
offset: 80,
|
||||||
duration: 1600,
|
duration: 1600,
|
||||||
type: 'success'
|
type: 'success'
|
||||||
})
|
});
|
||||||
this.$emit('refresh');
|
this.$emit('refresh');
|
||||||
this.$emit('endCopy');
|
this.$emit('endCopy');
|
||||||
}, 350);
|
}, 350);
|
||||||
|
@ -204,3 +204,13 @@ export function formatDoc(content) {
|
|||||||
})
|
})
|
||||||
return doc
|
return doc
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function fixCodeWhiteSpace(value = 'pre') {
|
||||||
|
const preDomList = document.getElementsByClassName('code__pre');
|
||||||
|
|
||||||
|
if (preDomList.length > 0) {
|
||||||
|
preDomList.forEach(pre=> {
|
||||||
|
pre.style.whiteSpace = value;
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
@ -236,17 +236,6 @@ export default {
|
|||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.leftAndRightScroll()
|
this.leftAndRightScroll()
|
||||||
},
|
|
||||||
watch: {
|
|
||||||
isCoping(newVal) {
|
|
||||||
const preDomList = document.getElementsByClassName('code__pre');
|
|
||||||
|
|
||||||
if (preDomList.length > 0) {
|
|
||||||
preDomList.forEach(pre=> {
|
|
||||||
pre.style.whiteSpace = newVal ? 'pre' : 'normal';
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user