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

@laoliangfe/annotation-overlay

v1.1.7

Published

基于 Fabric.js 的 Vue3 网页/图片标注组件,支持画笔、折线、箭头、矩形、椭圆、文字标注,撤销重做,导出 base64/Blob

Readme

@laoliangfe/annotation-overlay

一个基于 Fabric.js 的 Vue 3 页面标注组件,支持画笔、矩形、椭圆、箭头、折线和文字标注。

✨ 特性

  • 🎨 多种标注工具:画笔、矩形、椭圆、箭头、折线、文字
  • 📦 基于 Fabric.js 7.x,功能强大
  • 🚀 快速截图:使用 snapdom 替代 html2canvas
  • ↩️ 撤销/重做:完整的操作历史管理
  • 🎯 精确坐标:支持高 DPI 屏幕
  • 📱 响应式设计:适配不同屏幕尺寸
  • 🎨 可定制样式:粗细、颜色、大小
  • 🔄 可拖动工具栏:避免遮挡内容
  • ⌨️ 键盘快捷键:Ctrl+Z 撤销,Ctrl+Shift+Z 重做

📦 安装

npm install @laoliangfe/annotation-overlay
# 或
yarn add @laoliangfe/annotation-overlay
# 或
pnpm add @laoliangfe/annotation-overlay

🚀 快速开始

  • 全局注册
// main.ts
import { createApp } from 'vue';
import App from './App.vue';
import AnnotationOverlay from '@laoliangfe/annotation-overlay';
import '@laoliangfe/annotation-overlay/style.css';

const app = createApp(App);
app.use(AnnotationOverlay);
app.mount('#app');
  • 局部使用
<template>
  <div>
    <button @click="openAnnotation">📝 添加标注</button>
    
    <AnnotationOverlay 
      ref="annoRef" 
      @confirm="handleConfirm" 
      @cancel="handleCancel"
      @before-capture="cleanupBeforeCapture"
    />
    
    <div ref="targetRef" class="content">
      <!-- 你的内容 -->
    </div>
  </div>
</template>

<script setup lang="ts">
import { ref } from 'vue'
import AnnotationOverlay from '@laoliangfe/annotation-overlay'
import '@laoliangfe/annotation-overlay/style.css'

const annoRef = ref<InstanceType<typeof AnnotationOverlay>>()
const targetRef = ref<HTMLElement>()

const openAnnotation = () => {
  if (targetRef.value) {
    annoRef.value?.open(targetRef.value)
  }
}

const handleConfirm = (payload: ConfirmPayload | null) => {
  if (!payload) {
    console.log('未进行任何标注')
    return
  }
  console.log('标注结果:', payload)
  // 上传或保存
}

const handleCancel = () => {
  console.log('取消标注')
}

const cleanupBeforeCapture = (targetEl: HTMLElement) => {
  targetEl.querySelectorAll('.active, .hover').forEach(el => {
    el.classList.remove('active', 'hover')
  })
}
</script>

🎯 API

事件

| 事件名 | 参数 | 说明 | | :--: | :--------: | :---------- | | confirm | ConfirmPayload \| null | 确认标注,无内容时返回 null | | cancel | - | 取消标注| | beforeCapture | targetEl: HTMLElement | 截图前触发,可用于清理状态 | | afterCapture | targetEl: HTMLElement | 截图后触发,可用于恢复状态 |

方法

|方法 |参数 |说明| | :--: | :--------: | :---------- | | open | targetEl?: HTMLElement | 打开标注组件 | | close | - |关闭标注组件|

使用

const annoRef = ref<InstanceType<typeof AnnotationOverlay>>()

// 打开
annoRef.value?.open(document.querySelector('.target'))

// 关闭
annoRef.value?.close()

⌨️ 键盘快捷键

| 快捷键| 功能| | :--: | :---------- | |Ctrl+Z / Cmd+Z| 撤销| |Ctrl+Shift+Z / Cmd+Shift+Z| 重做| |Ctrl+Y / Cmd+Y| 重做| |ESC |退出文字编辑 / 取消|

🔧 开发

# 克隆仓库
git clone https://github.com/love2157dream/annotation-overlay.git

# 安装依赖
npm install

# 启动开发服务
npm run dev

# 构建
npm run build

# 运行测试
npm run test

📄 许可证

MIT © [Liang lei]