@tidbcloud/tisqleditor-vue

tisqleditor vue component
1,221
Install
npm install @tidbcloud/tisqleditor-vue
Latest Version:0.0.6
Vue:3
License:MIT
Last Updated:Aug 1, 2024
Links: npm
Maintainer: peakybingy

@tidbcloud/tisqleditor-vue

This package provides a vue component wrap for SQLEditorInstance from @tidbcloud/tisqleditor.

Installation

npm install @tidbcloud/tisqleditor-vue

You need to install all its peer dependencies manually as well, such as @codemirror/view, @codemirror/state.

Usage

@tidbcloud/tisqleditor-vue supports multiple CodeMirror instances, it uses EditorCacheProvide to cache the instances, then you can access all the cached editor instances anywhere inside the provide. You can put the provide in a proper place.

<script setup>
import { EditorCacheProvide, SQLEditor } from '@tidbcloud/tisqleditor-vue'
</script>

<template>
  <EditorCacheProvide>
    <SQLEditor editorId="test" doc="select * from test;" />
  </EditorCacheProvide>
</template>

When EditorCacheProvide unmounts, it will clear all the cached editor instances.

API

EditorCacheProvide

  • const cache=inject('editor-cache'): get the cache
  • cache.addEditor(editorId, instance): add new editor instance
  • cache.getEditor(editorId): get the cached editor instance by editorId
  • cache.deleteEditor(editorId): remove the editor instance from cache
  • cache.clearEditors(): clear all cached editor instances

SQLEditor Props

  • class: CodeMirror root container css class
  • editorId: editor id, used to differ multiple editor instances
  • doc: editor initial content
  • sqlConfig: config for SQL dialect, schemas, tables
  • theme: editor theme, @tidbcloud/codemirror-extensions-themes provides 2 simple themes, bbedit for light mode, oneDark for dark mode, you can choose any other themes from third-party libraries or customize it by self
  • extraExts: any other extra CodeMirror extensions you want to use, @tidbcloud/tisqleditor-react install some builtin extensions, likes @codemirror/lang-sql, @tidbcloud/codemirror-extension-sql-parser, @tidbcloud/codemirror-extension-cur-sql

Related Packages

vue-sql-editor

Simple SqlServer editor

1,214
vue-cm

CodeMirror component for Vue.js

969 45
monaco-vue3-editor

monaco vue3 editor,集成了 monaco-promql,简单易用的代码编辑器。

1,568 8
vue3-monaco-editor

A lightweight Monaco Editor component library for Vue 3.

1,333

Version History

Version Released Vue License
0.0.6 ^3.4.31 MIT
0.0.3 ^3.4.31 MIT
0.0.2 ^3.4.31 MIT
0.0.1 ^3.4.31 MIT