vue-shiki-input
TypeScript icon, indicating that this package has built-in type declarations

2.0.1 • Public • Published

vue-shiki-input

NPM Version NPM Downloads License

A Shiki input component for Vue.

Inspired by the awesome🤩 shiki playground from shiki-docs home.

Check out the docs!

🔨 Working on docs...

Installation

pnpm i vue-shiki-input

Usage

<script setup lang="ts">
import { ref } from 'vue'
import { VueShikiInput } from 'vue-shiki-input'
import 'vue-shiki-input/style.css'

const text = ref('const a = 1;')
</script>

<template>
  <VueShikiInput
    v-model="text"
    class="w-500px h-500px bg-gray-800 text-gray-200"
    :langs="['javascript']" :themes="['vitesse-dark']"
    :code-to-html-options="{
      lang: 'javascript',
      theme: 'vitesse-dark',
    }"
    :offset="{
      x: 10,
      y: 50,
    }"
    line-numbers
  />
</template>

Props

export interface VueShikiInputProps {
  /**
   * The code to be edited
   */
  modelValue: string
  /**
   * Disabled editor, will only render code
   */
  disabled?: boolean
  /**
   * Loading state, you should use v-model:loading to bind this prop
   */
  loading?: boolean
  /**
   * Automatically set background color based on the theme
   * @default false
   */
  autoBackground?: boolean
  /**
   * Preload languages, you can ignore this if you don't need to preload languages
   */
  langs?: (LanguageInput | string)[]
  /**
   * Preload themes, you can ignore this if you don't need to preload languages
   */
  themes?: (ThemeInput | string)[]
  /**
   * Same as codeToHTML props in shiki
   */
  codeToHtmlOptions?: CodeToHastOptions
  /**
   * Show line numbers
   */
  lineNumbers?: boolean
  /**
   * Line numbers color
   */
  lineNumbersColor?: string
  /**
   * Custom styles
   */
  styles?: {
    textareaClass?: string
    codeClass?: string
  }
  /**
   * Skip loading built-in themes and languages
   * This will be useful when you sure you don't need built-in themes and languages
   */
  skipLoadShikiBundled?: boolean
  /**
   * Editor offset
   * - x -> padding left+right
   * - y -> padding top+bottom
   */
  offset?: {
    x: number
    y: number
  }
  /**
   * Required when use customTheme, and cannot detect dark theme automatically (by type in theme)
   */
  darkTheme?: boolean
}

License

MIT

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
2.0.19latest

Version History

VersionDownloads (Last 7 Days)Published
2.0.19
1.2.00
1.1.30
1.1.20
1.1.10
1.1.00
1.0.30
1.0.20
1.0.10
1.0.00
0.2.50
0.2.40
0.2.30
0.2.20
0.2.10
0.1.01
0.0.10

Package Sidebar

Install

npm i vue-shiki-input

Weekly Downloads

10

Version

2.0.1

License

MIT

Unpacked Size

30 kB

Total Files

11

Last publish

Collaborators

  • alexzzz