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

@cp949/simple-html-editor-core

v0.2.0

Published

React에 의존하지 않는 HTML 편집기 정책과 Tiptap extension 집합

Readme

@cp949/simple-html-editor-core

서버 HTML을 편집기 문서로 읽고 정규화 HTML로 되돌리는 규칙을 제공하는 headless 패키지다. React에 의존하지 않는다.

React 애플리케이션이라면 이 패키지를 직접 설치하지 않고 @cp949/simple-html-editor-react를 사용한다. React 패키지가 이 패키지를 같은 버전의 runtime dependency로 포함한다. 이 패키지는 다른 프레임워크 adapter를 만들거나 UI 없이 HTML 정책만 적용할 때 사용한다.

설치

pnpm add @cp949/simple-html-editor-core

Tiptap 3.x runtime을 dependency로 포함한다. Editor나 EditorState 같은 Tiptap 타입을 직접 import하려면 소비자도 해당 패키지를 선언한다.

pnpm add @tiptap/core @tiptap/pm

공개 API

| symbol | 시그니처 | 역할 | | --- | --- | --- | | createHtmlEditorExtensions | (imageNodeViewRenderer?: NodeViewRenderer) => AnyExtension[] | HTML schema와 정규화 정책이 적용된 extension 집합을 만든다. | | isEditorDocumentEmpty | (document: JSONContent) => boolean | 저장할 텍스트, 이미지 또는 표가 없는 문서인지 판정한다. | | isAllowedLinkHref | (value: string) => boolean | 링크로 저장할 수 있는 URL인지 판정한다. | | isAllowedImageSrc | (value: string) => boolean | 이미지로 저장할 수 있는 URL 또는 bitmap data URL인지 판정한다. | | selectedImageAlignment | (state: EditorState) => 'left' \| 'center' \| 'right' \| null | 정확히 하나의 image node를 선택한 상태면 현재 가로 정렬을, 아니면 null을 돌려준다. |

이 패키지의 타입 선언은 @tiptap/core와 @tiptap/pm 타입을 노출한다. React 패키지의 공개 선언은 노출하지 않는다.

사용

import { Editor } from '@tiptap/core'
import { createHtmlEditorExtensions, isEditorDocumentEmpty } from '@cp949/simple-html-editor-core'

const editor = new Editor({
  element: document.querySelector('#editor') as HTMLElement,
  extensions: createHtmlEditorExtensions(),
  content: '<p>서버에서 받은 저장 HTML</p>',
})

// 저장할 값. 빈 문서는 undefined로 다룬다.
const html = isEditorDocumentEmpty(editor.getJSON()) ? undefined : editor.getHTML()

createHtmlEditorExtensions가 구성하는 extension은 StarterKit(link, underline 제외), Underline, 링크 정책이 적용된 Link, 이미지 정책이 적용된 Image, TextAlign, TextStyle, Color, TableKit이다. imageNodeViewRenderer를 전달하면 같은 image schema에 NodeView renderer만 연결한다. 저장 표현은 바뀌지 않는다.

extensions 배열을 소비자가 직접 수정하면 아래 저장 계약이 깨질 수 있다.

HTML 저장 계약

editor.getHTML() 결과는 입력 HTML과 바이트 단위로 같지 않다. 태그 wrapper, 공백과 속성 순서는 보존 계약이 아니다.

  • 허용 링크 protocol: http:, https:, mailto:, tel:과 상대 경로
  • 허용 이미지 protocol: http:, https:, blob:과 상대 경로
  • 허용 이미지 data URL: PNG, JPEG, GIF, WebP의 base64. SVG data URL은 거부한다.
  • <script>, <style>, iframe, 이벤트 속성과 지원하지 않는 inline style은 제거한다.

전체 계약은 HTML 저장 계약에 있다.

버전과 브라우저

  • @cp949/simple-html-editor-react와 항상 같은 버전으로 배포한다. 두 패키지를 함께 사용할 때는 버전을 일치시킨다.
  • 빌드 target은 Chrome 81이다.

링크

라이선스

MIT. 전문은 패키지의 LICENSE에 포함되어 있다.