npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

yanzi-monaco-editor

v0.3.7

Published

这是一个基于微软的monaco和vue封装的一个代码编辑器,浏览器可运行。主要功能有:html、javascript、css代码编辑,高亮显示,语法错误提示等,可以帮您的项目很快的拥有一个web端的代码编辑器

Downloads

72

Readme

燕子web代码编辑器

这是基于微软的monaco和vue封装的一个代码编辑器,浏览器可运行。主要功能有:html、javascript、css代码编辑,高亮显示,语法错误提示等,可以帮您很快的拥有一个web的代码编辑器

yanzi-monaco-editor

使用方法

使用方法

下载

npm i yanzi-monaco-editor

npm install --save [email protected]

npm install --save [email protected]

配置 vue.config.js

const MonacoWebpackPlugin = require('monaco-editor-webpack-plugin')
const CopyWebpackPlugin = require('copy-webpack-plugin')

module.exports = {
  configureWebpack:{
    plugins: [
      new MonacoWebpackPlugin(),
      new CopyWebpackPlugin([
        {
          from: 'node_modules/yanzi-monaco-editor/lib/editor.worker.js',
          to: 'static/js/editor.worker.js',
          toType: 'file'
        },
        {
          from: 'node_modules/yanzi-monaco-editor/lib/html.worker.js',
          to: 'static/js/html.worker.js',
          toType: 'file'
        },
        {
          from: 'node_modules/yanzi-monaco-editor/lib/css.worker.js',
          to: 'static/js/css.worker.js',
          toType: 'file'
        },
        {
          from: 'node_modules/yanzi-monaco-editor/lib/ts.worker.js',
          to: 'static/js/ts.worker.js',
          toType: 'file'
        },
        {
          from: 'node_modules/yanzi-monaco-editor/lib/json.worker.js',
          to: 'static/js/json.worker.js',
          toType: 'file'
        },
        {
          context: 'node_modules/yanzi-monaco-editor/lib/',
          from: '*.umd.min.*.js',
          to: 'static/js/',
          toType: 'dir'
        },

        {
          context: 'node_modules/yanzi-monaco-editor/lib/static/',
          from: 'fonts',
          to: 'static/js/fonts',
          toType: 'dir'
        }
      ])
    ]
  }
}
<template>
  <div id="app">
      
    <!-- 使用示例 -->
    <yanziMonacoEditor></yanziMonacoEditor>
      
  </div>
</template>

<script>
import 'yanzi-monaco-editor/lib/yanziMonacoEditor.css' // 引入基本样式
import yanziMonacoEditor from "yanzi-monaco-editor";// 引入核心文件

export default {
  name: "App",
  components: {
    yanziMonacoEditor //注册组件
  }
};
</script>

具体使用

<yanziMonacoEditor ref="editor" :settings="settings"></yanziMonacoEditor>

属性

| 属性名称 | 说明 | 类型 | 必填 | 默认值 | | ----------- | ------------------------------------------------------------ | ------- | ----- | ---------------------------- | | settings | 配置 | Object | false | - |

配置列表

| 配置名称 | 说明 | 类型 | 必填 | | -------- | ---------------- | ------ | ----- | | theme | 编辑器主题 | String | false | | className | 自定义类名 | String | false | | style | 样式,包括 width 、 height | Object | false |

方法

|方法名|说明|参数| |-|-|-| |getValue|获取编辑器最新内容|-| |run|执行编辑器内的代码(仅html和js可运行)|-|

完整使用示例

<template>
  <div id="app">
    <yanziMonacoEditor ref="editor" :settings="settings"></yanziMonacoEditor>
  </div>
</template>

<script>
import 'yanzi-monaco-editor/lib/yanziMonacoEditor.css'
import yanziMonacoEditor from 'yanzi-monaco-editor'
export default {
  name: 'App',
  components: { yanziMonacoEditor },
  data() {
    return {
      settings: {
        theme: 'vs-dark', // vs | vs-dark | hc-black
        className: '', // 自定义类名
        style: {
          width: '100%',
          height: '100%',
        },
      },
    }
  },
  methods: {
    getValue() {
      // 获取编辑器最新内容
      let value = this.$refs.editor.getValue()
      console.log(value)
    },
    run() {
      // 运行编辑器中的代码,仅html 、javascript 可运行
      this.$refs.editor.showView()
    },
    save() {
      // 可自定义的保存操作
      let value = this.$refs.editor.getValue()
      console.log(value)
    },
    keydown() {
      // 可绑定键盘事件
      let that = this
      document.onkeydown = function (e) {
        var keyCode = e.keyCode || e.which || e.charCode
        var ctrlKey = e.ctrlKey || e.metaKey
        if (ctrlKey) {
          switch (keyCode) {
            case 82: // -- ctrl + R  运行
              that.run()
              e.preventDefault()
              return false
            case 83: // -- ctrl + S 保存
              that.save()
              e.preventDefault()
              return false
          }
        }
      }
    },
  },
  mounted() {
    this.keydown()
  },
}
</script>

<style>
html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
}
#app {
  width: 100%;
  height: 100%;
}
#monaco {
  height: 100%;
}
</style>