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

variable-editor

v0.0.1

Published

rich text editor for insertion of variables in ai workflow

Downloads

6

Readme

variable-editor

中文 English

一个适用于 AI 工作流的富文本变量编辑器组件,基于 Vue 3 和 TipTap 实现。

介绍

variable-editor 是一个专为 AI 工作流设计的变量编辑器,它允许用户在富文本中方便地插入、编辑和管理变量。这些变量可以在 AI 提示词中作为占位符使用,便于构建动态的 AI 工作流程。

功能演示

特性

  • 🚀 便捷地在文本中插入和管理变量
  • 🔍 支持变量高亮显示
  • 🌲 支持层级结构变量
  • 🎨 可自定义样式
  • 📝 直观的文本编辑体验
  • 💼 适用于 AI 提示词、工作流配置等场景

安装

# npm
npm install variable-editor

# yarn
yarn add variable-editor

# pnpm
pnpm add variable-editor

使用方法

基础使用

<script setup lang="ts">
import { ref } from "vue";
import { VariableEditor } from "variable-editor";
import "variable-editor/dist/variable-editor.css";

// 定义变量
const variables = ref<VariableType[]>([
  {
    label: "用户输入",
    value: "input",
  },
  {
    label: "系统输出",
    value: "output",
  },
]);

// 绑定值
const value = ref<string>(
  "请处理{{#input.用户输入#}}并生成{{#output.系统输出#}}"
);
</script>

<template>
  <VariableEditor
    :variables="variables"
    v-model="value"
    width="100%"
    height="200px"
  />
</template>

层级结构变量

<script setup lang="ts">
import { ref } from "vue";
import { VariableEditor } from "variable-editor";
import "variable-editor/dist/variable-editor.css";

// 支持层级结构变量
const variables = ref<VariableType[]>([
  {
    label: "用户特征",
    value: "user_feature",
    children: [
      {
        label: "身高",
        value: "height",
      },
      {
        label: "体重",
        value: "weight",
      },
    ],
  },
]);

const value = ref<string>(
  "用户的{{#user_feature:height.用户特征:身高#}}是180cm"
);
</script>

数据结构

变量数据结构

interface VariableType {
  label: string; // 显示名称
  value: string; // 变量值
  children?: VariableType[]; // 子变量
}

输出格式

编辑器输出的字符串采用特殊格式,可以通过工具函数进行解析:

"{{#input.用户输入#}} 不为空,且 {{#output.系统输出#}} 正常"

工具函数

// 将字符串解析为纯文本内容
import { parseRichTextToContent } from "variable-editor";

const text = "{{#input.用户输入#}} 不为空";
const content = parseRichTextToContent(text); // "用户输入 不为空"

其他导出的工具函数:

  • parseRichTextEditorToString: 将编辑器 JSON 内容转换为格式化字符串
  • parseStringToRichTextEditor: 将格式化字符串转换为编辑器 JSON 内容

Props

| 属性 | 类型 | 默认值 | 描述 | | ---------- | ---------------- | -------- | -------------------------- | | variables | VariableType[] | [] | 变量列表 | | modelValue | string | - | 编辑器的值(v-model 绑定) | | width | string | '100%' | 编辑器宽度 | | height | string | '100%' | 编辑器高度 |

许可证

MIT