์ง๋ ฌํ
๊ธฐ๋ณธ ์ง๋ ฌํ ์ ํธ๋ฆฌํฐ๋ @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) => string | toPlainText ๊ฒฐ๊ณผ๋ฅผ 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๋ก ์ ๊ณตํฉ๋๋ค. ํจํค์ง ๋ฃจํธ์์๋
re-exportํ์ง ์์ผ๋ฏ๋ก(์๋ํฐ ๋ฒ๋ค์ remark/unified๊ฐ ๋ธ๋ ค์ค์ง ์๊ฒ),
๋ฐ๋์ subpath๋ก importํ์ธ์.
import { parseMarkdown, stringifyMarkdown } from '@inkio/editor/markdown';
// ๋๋ '@inkio/simple/markdown', '@inkio/core/markdown'Markdown round-trip์ core ๋ฒ์๊น์ง๋ง ๋ณด์ฅํฉ๋๋ค.
๊ตฌํ์ remark/unified ๊ธฐ๋ฐ์ด๋ฉฐ HTML bridge๋ฅผ ์ฌ์ฉํ์ง ์์ต๋๋ค.
Advanced ๋ ธ๋ ์ฒ๋ฆฌ
| ๋ ธ๋ | ๋ด๋ณด๋ด๊ธฐ | ๋ค์ ์ฝ๊ธฐ |
|---|---|---|
| ๋ฉ์ | @๋ผ๋ฒจ ํ
์คํธ | ํ ์คํธ ์ ์ง (์ด๋ฉ์ผ ์ค์ธ์ ๋ฐฉ์ง) |
| ํด์ํ๊ทธ | #๋ผ๋ฒจ ํ
์คํธ | ํ ์คํธ ์ ์ง |
| ์ํค๋งํฌ | [[์ด๋ฆ]] | ์ํค๋งํฌ ๋ ธ๋ ๋ณต์ (์์ ์๋ณต) |
| ๋ถ๋งํฌ | [์ ๋ชฉ](URL) ๋งํฌ | ๋งํฌ (์นด๋ ๋ณต์ ์ ๋จ) |
| ๋๊ธ | ๋ฒ๋ ค์ง (๋งํฌ ์ ๊ฑฐ, ํ ์คํธ ์ ์ง) | โ (์ค๋ ๋๋ ์๋ฒ์ ๋ณ๋ ์ ์ฅ) |
Last updated on