0.2.0 • Published 1 year ago

react-highlight-code-vue v0.2.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

Highlight Code and Content editor for Vue.js

Import the npm package and only one prop to show highlightCode and editor

vue 3

yarn add highlight.js vue-highlight-code

live demo

bitSandBox-demo(web-IDE部分模块的简单实现)

stackblitz

NXGUK Z% L$P EQCLJZ6TZY

1. use in Vue3

Install the vue-highlight-code package from NPM and highlight.js:

yarn add highlight.js vue-highlight-code

import the component and style

import { HighCode } from 'vue-highlight-code';
import 'vue-highlight-code/dist/style.css';
export default {
    components: {
      HighCode
    },
}

<HighCode></HighCoder>

Component Props

propdescriptiontypedefault
codeValueHighlight Code SourceString''
textEditorCodeText EditorBoolean'false'
langHighlight Code TypeStringjavascript (such as 'vue','html','css)
themeComponent Highlight Code themeStringdefault: dark(only 'dark','light')
codeLinesShow Code linesBooleanfalse
langNameHighlight Code Name (Upper left corner display)String
widthcomponent style widthString620px
heightcomponent style heightString
maxWidthcomponent style max-widthString
maxHightcomponent style max-heightStringString
fontSizehighlight code font-sizeString-
scrollStyleBoolcomponent scroll bar styleBooleantrue
copywhether the code can copyBooleantrue
borderRadiuscomponent style border_radiusString10px

emit

emitdescriptiontypeparameter
getCodeValueThe emit method is triggered when the edit content changesFunctionfunction(contentValue: String): void

Get real-time editing code content

create ref in the HighCode component instance get the modelValue

<script setup>
const H = ref(null)
onMounted(() => {
  console.log(H.value.modelValue)
})
<script>
<HighCode ref="H" ></HighCode>