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

tiptap_search_replace_plugin

v0.0.9

Published

A search and replace plugin for Tiptap editor

Readme

Tiptap 搜索替换插件

这是一个为 Tiptap 编辑器开发的搜索和替换功能插件。该插件允许用户在 Tiptap 编辑器中搜索文本并进行替换操作。

功能特点

  • 文本搜索功能
  • 查找下一个/上一个匹配项
  • 文本替换功能
  • 与 Tiptap 编辑器无缝集成

安装

使用 npm:

npm install tiptap_search_replace_plugin

使用 yarn:

yarn add tiptap_search_replace_plugin

使用 pnpm:

pnpm add tiptap_search_replace_plugin

使用方法

基本用法

import { Editor } from '@tiptap/core';
import { SearchReplacePlugin } from 'tiptap_search_replace_plugin';

const editor = new Editor({
  extensions: [
    // ... 其他扩展
    SearchReplacePlugin,
  ],
  // ... 其他配置
});

// 打开查找替换面板
editor.commands.openFindReplace();

// 关闭查找替换面板
editor.commands.closeFindReplace();

// 切换查找替换面板
editor.commands.toggleFindReplace();

// 搜索文本
editor.commands.find('要搜索的文本');

// 查找下一个匹配项
editor.commands.findNext();

// 查找上一个匹配项
editor.commands.findPrevious();

// 替换当前匹配项
editor.commands.replace('替换后的文本');

// 替换所有匹配项
editor.commands.replaceAll('替换后的文本');

API

该插件提供以下命令:

  • find(text: string): 搜索指定文本
  • findNext(): 查找下一个匹配项
  • findPrevious(): 查找上一个匹配项
  • replace(text: string): 替换当前匹配项
  • replaceAll(text: string): 替换所有匹配项
  • toggleFindReplace(): 打开或关闭查找替换面板
  • closeFindReplace(): 关闭查找替换面板
  • openFindReplace(): 打开查找替换面板

Style

该插件没有默认的样式。你可以根据需要自定义样式,例如:

.find-replace-highlight {
  background-color: yellow;
  &.find-replace-highlight-active {
    background-color: orange;
  }
}

开发

配置

你可以通过 openPanel 选项自定义打开查找替换面板的快捷键。默认值为 Mod-f(即按下 Ctrl+fCmd+f)。

const editor = new Editor({
  extensions: [
    // ... 其他扩展
    SearchReplacePlugin.configure({
      openPanel: 'Mod-f',
    }),
  ],
  // ... 其他配置
});

实例

import { Editor } from '@tiptap/core';
import { SearchReplacePlugin } from 'tiptap_search_replace_plugin';

const editor = new Editor({
  extensions: [
    // ... 其他扩展
    SearchReplacePlugin,
  ],
  // ... 其他配置
});

Event

该插件触发以下事件:

  • findReplace:toggleFindReplace(isOpen: boolean): 查找替换面板打开或关闭时触发

你可以使用 on 方法监听这些事件,例如:

useEffect(() => {
  editor.on("findReplace:toggleFindReplace", (isOpen) => updateState({ open: isOpen }));
  return () => {
    editor.off("findReplace:toggleFindReplace");
  };
}, []);

构建项目

# 安装依赖
pnpm install

# 开发模式
pnpm dev

# 构建
pnpm build

许可证

MIT