Skip to Content
์ง๋ ฌํ™”

์ง๋ ฌํ™”

๊ธฐ๋ณธ ์ง๋ ฌํ™” ์œ ํ‹ธ๋ฆฌํ‹ฐ๋Š” @inkio/editor์™€ @inkio/simple์—์„œ ๋‹ค์‹œ exportํ•ฉ๋‹ˆ๋‹ค.

import { toPlainText, toSummary, getContentStats } from '@inkio/editor'; import { extractMentions, extractHashtags } from '@inkio/advanced';

@inkio/core ์œ ํ‹ธ๋ฆฌํ‹ฐ

@inkio/editor์™€ @inkio/simple์—์„œ ๋‹ค์‹œ exportํ•˜๋ฉฐ, ๋ชจ๋‘ JSONContent๋ฅผ ์ž…๋ ฅ์œผ๋กœ ๋ฐ›์Šต๋‹ˆ๋‹ค.

ํ•จ์ˆ˜์‹œ๊ทธ๋‹ˆ์ฒ˜์„ค๋ช…
toPlainText(content) => string๋ชจ๋“  ํ…์ŠคํŠธ๋ฅผ ์ถ”์ถœํ•ด ํ•˜๋‚˜์˜ ์ผ๋ฐ˜ ํ…์ŠคํŠธ ๋ฌธ์ž์—ด๋กœ ๋ฐ˜ํ™˜ํ•ฉ๋‹ˆ๋‹ค. ์—ฐ์† ๊ณต๋ฐฑ/์ค„๋ฐ”๊ฟˆ์€ ์ •๋ฆฌ๋˜๊ณ  ์•ž๋’ค ๊ณต๋ฐฑ์€ ์ œ๊ฑฐ๋ฉ๋‹ˆ๋‹ค.
toSummary(content, maxLength = 140) => stringtoPlainText ๊ฒฐ๊ณผ๋ฅผ maxLength๊นŒ์ง€ ์ž˜๋ผ๋‚ธ ์š”์•ฝ์„ ๋ฐ˜ํ™˜ํ•ฉ๋‹ˆ๋‹ค. ๊ธธ์ด๋ฅผ ์ดˆ๊ณผํ•˜๋ฉด ๋์— ...์ด ๋ถ™์Šต๋‹ˆ๋‹ค.
getContentStats(content) => { words: number; chars: number; blocks: number }๋‹จ์–ด ์ˆ˜, ๋ฌธ์ž ์ˆ˜, ๋ธ”๋ก ์ˆ˜๋ฅผ ๋‹ด์€ ๊ฐ์ฒด๋ฅผ ๋ฐ˜ํ™˜ํ•ฉ๋‹ˆ๋‹ค. words/chars๋Š” ์ผ๋ฐ˜ ํ…์ŠคํŠธ ๊ธฐ์ค€์ž…๋‹ˆ๋‹ค.
const summary = toSummary(content, 80); const { words, chars, blocks } = getContentStats(content);

@inkio/advanced ์œ ํ‹ธ๋ฆฌํ‹ฐ

ํ•จ์ˆ˜์‹œ๊ทธ๋‹ˆ์ฒ˜์„ค๋ช…
extractMentions(content) => Array<{ id: string; label: string }>๋ฌธ์„œ์— ํฌํ•จ๋œ ๋ฉ˜์…˜ ๋…ธ๋“œ๋ฅผ ์ถ”์ถœํ•ฉ๋‹ˆ๋‹ค. id/label ์กฐํ•ฉ์ด ๊ฐ™์€ ํ•ญ๋ชฉ์€ ์ค‘๋ณต ์ œ๊ฑฐ๋ฉ๋‹ˆ๋‹ค.
extractHashtags(content) => string[]๋ฌธ์„œ์— ํฌํ•จ๋œ ํ•ด์‹œํƒœ๊ทธ ๋ผ๋ฒจ์„ ์ถ”์ถœํ•ฉ๋‹ˆ๋‹ค. ์„ ํ–‰ #๋Š” ์ œ๊ฑฐ๋˜๋ฉฐ ์ค‘๋ณต๋„ ์ œ๊ฑฐ๋ฉ๋‹ˆ๋‹ค.
const mentions = extractMentions(content); // [{ id: 'u1', label: 'Alice' }] const tags = extractHashtags(content); // ['inkio', 'editor']

Markdown import/export๋Š” ๋ณ„๋„ subpath๋กœ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค.

import { parseMarkdown, stringifyMarkdown } from '@inkio/editor/markdown';

Markdown round-trip์€ core ๋ฒ”์œ„๊นŒ์ง€๋งŒ ๋ณด์žฅํ•ฉ๋‹ˆ๋‹ค. ๊ตฌํ˜„์€ remark/unified ๊ธฐ๋ฐ˜์ด๋ฉฐ HTML bridge๋ฅผ ์‚ฌ์šฉํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.

Last updated on