Skip to content

vue 2 version of "@vue/repl" #31

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Mar 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .env

This file was deleted.

3 changes: 0 additions & 3 deletions .env.deploy

This file was deleted.

3 changes: 0 additions & 3 deletions .env.play

This file was deleted.

3 changes: 0 additions & 3 deletions .env.production

This file was deleted.

14 changes: 0 additions & 14 deletions .eslintignore

This file was deleted.

23 changes: 0 additions & 23 deletions .eslintrc.js

This file was deleted.

27 changes: 13 additions & 14 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
.DS_Store
node_modules
/dist
/lib/*.html
/lib/*.html.gz
/deploy

# local env files
.env.local
.env.*.local

# Log files
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
*pnpm-debug.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
dist
dist-ssr
*.local

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.vscode
.DS_Store
*.suo
*.ntvs*
*.njsproj
Expand Down
24 changes: 0 additions & 24 deletions .npmignore

This file was deleted.

5 changes: 0 additions & 5 deletions .prettierignore

This file was deleted.

3 changes: 0 additions & 3 deletions .prettierrc.js

This file was deleted.

20 changes: 0 additions & 20 deletions .travis.yml

This file was deleted.

85 changes: 10 additions & 75 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,83 +14,21 @@

English | [简体中文](./README.zh-CN.md)

A lightweight code interaction component based on `vue 2.x`, which can edit, run and preview the code effect display in real time on the web page.
Vue SFC REPL as a Vue 2.7 component.

When reading docs that contain a lot of code, many project docs implement a `render` representation of the sample code via the `markdown loader`, but it is static. When we want to debug code, we generally need to open the local IDE or open online editor websites such as `codepen`, `codesandbox`, and it is also subject to whether the computer has a development environment installed or whether the network connection is smooth.
## 💻 Simple Usage

So can there be such a component that can support editing code in the page, edit, run and preview the code effect display in real time in the web page?
```vue
<script setup>
import { Repl } from 'vue-code-view'
import 'vue-code-view/style.css'
</script>

Special thanks to the component [react-code-view](https://github.com/simonguo/react-code-view), based on which the vue version of the component was written! Using this component, you can edit the running code and preview the effect in real time by using the multi-sample code in the `vue` page or the `markdown` document.

## ⚡ Online Demo

![示例][preview-ol-v03]

demo address: <https://andurils.github.io/vue-code-view/#/demo>

`codesandbox` example: [vue-code-view-example](https://codesandbox.io/s/vue-code-view-example-forked-nivmw?fontsize=14&hidenavigation=1&theme=dark)

## ✨ Features

- 💻 Code can be edited online and preview the effect in real time.
- 🎨 Support sample code highlighting, configure themes.
- 🌈 Support `<style>` parsing and rendering.
- 📑 Support `Markdown` file example rendering

## 📦 Install

```bash
npm i vue-code-view
# or
yarn add vue-code-view
```

## 🔨 Configure

Using `vue cli` requires configuration in the `vue.config.js` file, which supports the use of Vue builds that include the runtime compiler.

```javascript
module.exports = {
runtimeCompiler: true,
// or
chainWebpack: (config) => {
config.resolve.alias
.set("vue$", "vue/dist/vue.esm.js");
},
};
<template>
<Repl />
</template>
```

## 💻 Usage

Components are introduced in the entry file `main.js`, and there is no need to manually introduce styles.

```javascript
import Vue from "vue";
import App from "./App.vue";
import CodeView from "vue-code-view";

Vue.use(CodeView);

new Vue({
router,
store,
render: (h) => h(App),
}).$mount("#app");
```

## 📚 API

### Props

| Property | Description | Type | Default | Version |
| --- | ----- | ---- | ----- | ---- |
| themeMode | code editor theme mode,default `light` | `` \| `dark` | `` | |
| showCode | show the code editor , only `layout` value is `top` takes effect | boolean | false | |
| source | source code | string | - | |
| layout | render view layout | `top` \| `right` \| `left` | `top` | `0.4.0+` |

<!-- ### Events -->

## 📋 Changelog

Detailed changes for each release are documented in the [release notes](./CHANGELOG.zh-CN.md).
Expand All @@ -105,7 +43,4 @@ VCV is licensed under the terms of the [MIT License](./LICENSE).

Copyright (c) 2021-present Anduril

[preview-ol]: https://p9-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/912bf867ef4c44d3a716e4bf723573ac~tplv-k3u1fbpfcp-watermark.image?
[preview-ol-v01]:https://p3-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/e056aef106b04752bde86e5bc48434c9~tplv-k3u1fbpfcp-watermark.image?
[preview-ol-v02]:https://p1-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/4550d42d98084cf99fe333fadb3f5983~tplv-k3u1fbpfcp-watermark.image?
[preview-ol-v03]:https://p3-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/987ab9814e314f92a244fdf6510e6224~tplv-k3u1fbpfcp-watermark.image?
56 changes: 56 additions & 0 deletions api-extractor.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",

"projectFolder": ".",

"mainEntryPointFilePath": "./dist/src/index.d.ts",

"dtsRollup": {
"enabled": true
},

"apiReport": {
"enabled": false
},

"docModel": {
"enabled": false
},

"tsdocMetadata": {
"enabled": false
},

"messages": {
"compilerMessageReporting": {
"default": {
"logLevel": "warning"
}
},

"extractorMessageReporting": {
"default": {
"logLevel": "warning",
"addToApiReportFile": true
},

"ae-forgotten-export": {
"logLevel": "none"
},

"ae-missing-release-tag": {
"logLevel": "none"
}
},

"tsdocMessageReporting": {
"default": {
"logLevel": "warning"
},

"tsdoc-undefined-tag": {
"logLevel": "none"
}
}
}
}
3 changes: 0 additions & 3 deletions babel.config.js

This file was deleted.

69 changes: 0 additions & 69 deletions build/markdown-loader/index.js

This file was deleted.

13 changes: 0 additions & 13 deletions build/markdown-loader/util.js

This file was deleted.

Loading