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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@ulearning/vue3-editor

v1.0.4

Published

Vue 3 rich text editor wrapper based on TinyMCE

Readme

@ulearning/vue3-editor

基于 TinyMCE 5.8.2 的 Vue 3 富文本编辑器组件,内置常用工具栏、语言包、图片上传和 TypeScript 类型声明。

安装

npm install @ulearning/vue3-editor

组件样式已打包,无需额外引入 TinyMCE CSS。

基本使用

<template>
  <UlEditor
    ref="editorRef"
    v-model="content"
    language="zh"
    :height="460"
    :options="editorOptions"
    :uploader-config="uploaderConfig"
    @ready="handleReady"
    @change="handleChange"
    @upload-error="handleUploadError"
  />
</template>

<script setup lang="ts">
import { ref } from 'vue'
import {
  UlEditor,
  type RawEditorOptions,
  type TinyMCEEditor,
  type UlEditorExpose,
  type UploaderConfig,
} from '@ulearning/vue3-editor'

const editorRef = ref<UlEditorExpose | null>(null)
const content = ref('<p>编辑器初始内容</p>')
const editorOptions: RawEditorOptions = { add_unload_trigger: false }
const uploaderConfig: UploaderConfig = {
  mode: 'huawei',
  uptokenHost: 'https://your-api.example.com',
  authorization: 'your-login-token',
}

function handleReady(editor: TinyMCEEditor) {
  console.log('editor ready', editor)
}

function handleChange(html: string) {
  console.log('content changed', html)
}

function handleUploadError(message: string) {
  console.error(message)
}

function readContent() {
  return editorRef.value?.getContent() || ''
}
</script>

也可以全局注册:

import { createApp } from 'vue'
import UlEditor from '@ulearning/vue3-editor'
import App from './App.vue'

createApp(App).use(UlEditor).mount('#app')

图片上传

华为 OBS

不传 uploadHandler 时,组件使用 ulearning-obs 上传。当前示例需要以下配置:

const uploaderConfig: UploaderConfig = {
  mode: 'huawei',
  uptokenHost: 'https://your-api.example.com',
  authorization: loginToken,
}

永久 AK/SK 不应写入前端。authorization 应使用登录态或后端签发的短期凭证。

自定义上传

传入 uploadHandler 后将完全接管图片上传,返回值必须是可持久访问的图片 URL,不能返回 Base64 或 blob: 临时地址。

async function uploadImage(file: Blob) {
  const form = new FormData()
  form.append('file', file, (file as File).name || `image-${Date.now()}.png`)

  const response = await fetch('/api/uploads/images', {
    method: 'POST',
    body: form,
  })
  if (!response.ok) throw new Error('图片上传失败')

  const result = await response.json()
  return result.url
}
<UlEditor v-model="content" :upload-handler="uploadImage" />

默认图片大小上限为 5 MB,可通过 maxImageSize 修改。图片类型通过 options.fileTypeLimit.image 配置:

const editorOptions: RawEditorOptions = {
  fileTypeLimit: {
    image: '.png,.jpg,.jpeg,.gif,.bmp',
  },
}

工具栏和插件

默认工具栏:

undo redo | fontselect | fontsizeselect | bold italic underline forecolor removeformat | numlist bullist indentgroup aligngroup | table imageupload

使用 toolbarOptions 自定义工具栏:

<UlEditor
  v-model="content"
  toolbar-options="undo redo | bold italic | searchreplace link formula"
  formula-url="https://your-formula-page.example.com"
/>

searchreplacelinkformula 会根据工具栏配置按需加载。使用 formula 时必须同时提供可访问的 formulaUrl

视频或音频按钮需要在 toolbarOptions 中加入 videouploadaudioupload,并传入 uploadFile(file, type, editor)

语言

通过 language 传入 TinyMCE 语言代码。英语使用 TinyMCE 默认文本,不需要额外语言文件。

| 语言 | language | | --- | --- | | English | en | | 中文 | zh | | 繁體中文 | tw | | Indonesia | id | | ไทย | th | | español | es | | العربية | ar | | français | fr | | português | pt | | русский | ru | | o'zbek | uz | | አማርኛ | am | | italiano | it | | Kiswahili | sw |

Props

| Prop | 类型 | 默认值 | 说明 | | --- | --- | --- | --- | | modelValue | string | '' | v-model 内容 | | value | string | undefined | 兼容旧版内容属性 | | height | number \| string | 500 | 编辑器高度 | | width | number \| string | '100%' | 编辑器宽度 | | allowPaste | boolean | true | 是否允许粘贴 | | autoFocus | boolean | false | 初始化后是否聚焦 | | toolbarOptions | string | 默认工具栏 | TinyMCE 工具栏配置 | | options | RawEditorOptions | {} | 其他 TinyMCE 配置 | | uploaderConfig | UploaderConfig | {} | ulearning-obs 配置 | | uploadHandler | ImageUploadHandler | null | 自定义图片上传方法 | | uploadFile | FileUploadHandler | null | 视频或音频上传方法 | | maxImageSize | number | 5 * 1024 * 1024 | 图片大小上限,单位为字节 | | language | string | 'en' | 编辑器语言代码 | | formulaUrl | string | '' | 公式编辑页面地址 |

options 会合并到默认 TinyMCE 配置中。默认已设置 add_unload_trigger: false,组件卸载时会调用 TinyMCE 实例的 remove()

事件

| 事件 | 参数 | 说明 | | --- | --- | --- | | update:modelValue | html: string | 内容变化时更新 v-model | | change | html: string | TinyMCE change 事件 | | onChange | html: string | 兼容旧版事件名 | | ready | editor: TinyMCEEditor | 编辑器初始化完成 | | uploadError | message: string | 图片上传失败 |

公开方法

通过组件 ref 调用:

editorRef.value?.getEditor()
editorRef.value?.getContent()
editorRef.value?.setContent('<p>新内容</p>')

| 属性或方法 | 说明 | | --- | --- | | editor | 当前 TinyMCE 实例 | | editorComponent | 编辑器宿主 textarea | | getEditor() | 返回 TinyMCE 实例 | | getContent() | 返回当前 HTML | | setContent(html) | 替换内容并重置撤销记录 |

本地开发

npm install
npm run dev

运行完整检查:

npm run check

该命令依次执行 Vue/TypeScript 类型检查、发布类型检查、生产构建和包测试。源码示例位于 examples/