SSR (μλ² μ¬μ΄λ λ λλ§)
Inkioλ Next.js App Router νκ²½μμ SSRμ μ§μν©λλ€.
λμ λ°©μ
- μλ²:
generateHTML(@tiptap/html)λ‘ μ μ HTML μμ± - ν΄λΌμ΄μΈνΈ: μ μ HTMLμ SSR shellλ‘ νμ β Tiptap μλν°κ° hydration ν λ체
SSR shellμ ν΄λΌμ΄μΈνΈμ λμΌν HTMLμ μμ±νλ―λ‘ hydration mismatchκ° λ°μνμ§ μμ΅λλ€.
μ€μ
λ³λ μ€μ μμ΄ λμν©λλ€. Editorμ Viewer μ»΄ν¬λνΈκ° μλμΌλ‘ SSRμ μ²λ¦¬ν©λλ€.
// Next.js App Router β μλ SSR
import { Editor } from '@inkio/editor';
import '@inkio/editor/style.css';
export default function Page() {
return <Editor initialContent={content} />;
}HTML λ¬Έμμ΄ μ λ ₯
content propμ HTML λ¬Έμμ΄μ μ λ¬νλ©΄, μλ²μμλ sanitize-htmlλ‘ XSSλ₯Ό λ°©μ§ν ν λ λλ§ν©λλ€.
<Editor content="<p>Hello <strong>World</strong></p>" />보μ
- JSON μ½ν
μΈ :
@tiptap/htmlμ DOM κΈ°λ° λ λλ§μΌλ‘ ν μ€νΈ λ Έλ μλ μ΄μ€μΌμ΄ν - HTML λ¬Έμμ΄:
sanitize-htmlνμ΄νΈλ¦¬μ€νΈ κΈ°λ° νν°λ§ - νμ©λ μ€νμΌ:
color,background-color,text-alignλ§ νμ© - μ°¨λ¨λ νλ‘ν μ½:
javascript:,data:,vbscript:
μ£Όμμ¬ν
parseMarkdownμ DOMμ΄ νμνλ―λ‘ λͺ¨λ λ 벨μμ νΈμΆν μ μμ΅λλ€'use client'μ§μμ΄λ Editor/Viewer μ»΄ν¬λνΈμ μ΄λ―Έ ν¬ν¨λμ΄ μμ΅λλ€
Last updated on