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

@edgex-fe/editor-preview

v0.0.4

Published

Framework-agnostic EdgeX editor content preview renderer

Readme

@edgex-fe/editor-preview

@edgex-fe/editor-preview 是基于 EdgeX UI 规范的富文本预览组件,用于渲染富文本编辑器返回的 HTML 内容。组件内置统一的排版样式和 HTML 清理逻辑,可在 React、Vue 或原生 Web 项目中使用。

安装

pnpm add @edgex-fe/editor-preview

在应用入口引入样式:

import "@edgex-fe/editor-preview/styles.css";

React

在 React 中可以基于包提供的样式和 HTML 清理函数封装组件:

import {
  getEditorClassName,
  sanitizeEditorHtml,
  type EditorHtml,
} from "@edgex-fe/editor-preview";
import "@edgex-fe/editor-preview/styles.css";

interface EditorPreviewProps {
  html: EditorHtml;
  className?: string;
}

export function EditorPreview({ html, className }: EditorPreviewProps) {
  return (
    <div
      className={getEditorClassName(className)}
      dangerouslySetInnerHTML={{ __html: sanitizeEditorHtml(html) }}
    />
  );
}

使用组件:

<EditorPreview html={editorHtml} />

Vue

Vue 项目可以直接使用包内置的 Custom Element。在应用入口注册一次:

import { defineEditorElement } from "@edgex-fe/editor-preview";
import "@edgex-fe/editor-preview/styles.css";

defineEditorElement();

在组件中传入编辑器返回的 HTML:

<script setup lang="ts">
defineProps<{
  html: string;
}>();
</script>

<template>
  <edgex-editor-preview :html="html" />
</template>

如果项目使用 Vite,需要让 Vue 编译器将该标签识别为 Custom Element:

import vue from "@vitejs/plugin-vue";
import { defineConfig } from "vite";

export default defineConfig({
  plugins: [
    vue({
      template: {
        compilerOptions: {
          isCustomElement: (tag) => tag === "edgex-editor-preview",
        },
      },
    }),
  ],
});

HTML 安全

组件默认会清理 HTML 中的脚本、事件属性和危险链接。React 示例显式调用了 sanitizeEditorHtml,Vue 的 Custom Element 会在渲染时自动执行相同的清理逻辑。

只有在 HTML 来源完全可信时,才应通过 renderEditorsanitize: false 选项跳过清理。