-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use pygments support code highlight dynamically.
- Loading branch information
1 parent
31f66ef
commit b239d64
Showing
4 changed files
with
152 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
<template> | ||
<div ref="scrollArea" class="code-box"> | ||
<div v-html="content"/> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
export default { | ||
name: 'PreviewCodeHtml', | ||
components: { | ||
}, | ||
props: { | ||
file: String, | ||
size: Number, | ||
backgroundColor: String, | ||
content: String | ||
}, | ||
watch: { | ||
file: function() { | ||
this.$refs.scrollArea.scrollTop = 0; | ||
} | ||
}, | ||
mounted() { | ||
var that = this; | ||
this.$root.$on("previewToggle", function() { | ||
that.scrollUp(); | ||
}); | ||
this.$root.$on("scrollUp", function() { | ||
that.scrollUp(); | ||
}); | ||
this.$root.$on("scrollDown", function() { | ||
that.scrollDown(); | ||
}); | ||
this.$root.$on("scrollUpLine", function() { | ||
that.scrollUpLine(); | ||
}); | ||
this.$root.$on("scrollDownLine", function() { | ||
that.scrollDownLine(); | ||
}); | ||
}, | ||
created() { | ||
}, | ||
methods: { | ||
scrollUp() { | ||
this.$refs.scrollArea.scrollTop = this.$refs.scrollArea.scrollTop + this.$refs.scrollArea.clientHeight; | ||
}, | ||
scrollDown() { | ||
this.$refs.scrollArea.scrollTop = this.$refs.scrollArea.scrollTop - this.$refs.scrollArea.clientHeight; | ||
}, | ||
scrollUpLine() { | ||
this.$refs.scrollArea.scrollTop = this.$refs.scrollArea.scrollTop + 50; | ||
}, | ||
scrollDownLine() { | ||
this.$refs.scrollArea.scrollTop = this.$refs.scrollArea.scrollTop - 50; | ||
} | ||
} | ||
} | ||
</script> | ||
|
||
<!-- Add "scoped" attribute to limit CSS to this component only --> | ||
<style scoped> | ||
.code-box { | ||
width: 100%; | ||
height: 100%; | ||
overflow: scroll; | ||
padding-left: 15px; | ||
font-size: 18px; | ||
} | ||
</style> |