ํ์ฅ
Inkio ํ์ฅ์ ๋ ์ธต์ผ๋ก ๋๋ฉ๋๋ค.
@inkio/core- callout
- details/toggle
- table
- keyboard shortcuts
@inkio/advanced- slash command
- block handle
- mention
- hashtag
- wiki link
- bookmark
- comment
๊ถ์ฅ ์์์
- classic editor๊ฐ ํ์ํ๋ฉด
@inkio/simple - notion-like editor๊ฐ ํ์ํ๋ฉด
@inkio/editor - low-level ์กฐํฉ์ด ํ์ํ๋ฉด
@inkio/core๋๋@inkio/advanced
์กฐํฉ ์์
import { Editor } from '@inkio/core';
import { getDefaultExtensions } from '@inkio/advanced';
import '@inkio/core/minimal.css';
import '@inkio/advanced/style.css';
const extensions = getDefaultExtensions({
hashtagItems: ({ query }) => [{ id: query || 'inkio', label: `#${query || 'inkio'}` }],
});
export function Page() {
return <Editor extensions={extensions} initialContent="<p>Hello Inkio</p>" />;
}Image editor
import { Editor } from '@inkio/editor';
import { ImageEditorModal } from '@inkio/image-editor';
import '@inkio/image-editor/style.css';
export function Page() {
return (
<Editor
onImageUpload={async (file) => URL.createObjectURL(file)}
imageBlock={{ imageEditor: ImageEditorModal }}
/>
);
}TocBlock (์ธ๋ผ์ธ ๋ชฉ์ฐจ)
@inkio/core์ ๊ธฐ๋ณธ ํฌํจ๋ฉ๋๋ค. ๋ฌธ์ ์์ Notion ์คํ์ผ์ ์ธ๋ผ์ธ ๋ชฉ์ฐจ ๋ธ๋ก์ ์ฝ์
ํฉ๋๋ค.
์ฐธ๊ณ : ์๋ํฐ ์ธ๋ถ์ ์ค๋ฒ๋ ์ด ๋ฏธ๋๋งต ํํ๋ก ํ์ํ๋ ค๋ฉด
<ToC>์ปดํฌ๋ํธ๋ฅผ ์ฌ์ฉํ์ธ์. ์ปดํฌ๋ํธ ๋ฌธ์ ์ฐธ๊ณ
/toc์ฌ๋์ ์ปค๋งจ๋๋ก ์ฝ์ (@inkio/advancedSlashCommand ํ์)- ํค๋ฉ์ด ์ถ๊ฐ/์์ /์ญ์ ๋๋ฉด ์๋์ผ๋ก ์ ๋ฐ์ดํธ๋ฉ๋๋ค
- ํญ๋ชฉ ํด๋ฆญ ์ ํด๋น ํค๋ฉ์ผ๋ก ์คํฌ๋กค๋ฉ๋๋ค
- ๋ฐฐ๊ฒฝ/ํ ๋๋ฆฌ ์๋ Notion ์คํ์ผ ๋ฏธ๋๋ฉ ๋์์ธ (ํ ์คํธ ๋งํฌ๋ง)
- ํค๋ฉ์ด ์์ผ๋ฉด muted ํ๋ ์ด์คํ๋ ํ์: โAdd headings to see the table of contents.โ
๋นํ์ฑํํ๋ ค๋ฉด getExtensions์ tocBlock: false๋ฅผ ์ ๋ฌํฉ๋๋ค:
import { getExtensions } from '@inkio/core';
const extensions = getExtensions({ tocBlock: false });CodeBlock (์ฝ๋ ๋ธ๋ก)
@inkio/core์ ๊ธฐ๋ณธ ํฌํจ๋๋ฉฐ, lowlight ๊ธฐ๋ฐ ๊ตฌ๋ฌธ ๊ฐ์กฐ๋ฅผ ์ ๊ณตํฉ๋๋ค. 37๊ฐ์ ์ผ๋ฐ์ ์ธ ์ธ์ด๋ฅผ ์ง์ํฉ๋๋ค.
- ์๋ํฐ ๋ชจ๋: ํ๋กํ ์ธ์ด ์ ํ๊ธฐ(๋๋กญ๋ค์ด)๋ก ์ธ์ด ๋ณ๊ฒฝ
- ๋ทฐ์ด ๋ชจ๋: ๋ณต์ฌ ๋ฒํผ + ์ธ์ด ๋ฐฐ์ง ํ์
tsx/jsx๋ ๊ฐ๊ฐtypescript/javascript์ ๋ณ์นญ์ผ๋ก ์ฒ๋ฆฌ๋ฉ๋๋ค
์ฝ๋ ๋ธ๋ก์ ๋นํ์ฑํํ๋ ค๋ฉด codeBlock={false}๋ฅผ ์ ๋ฌํฉ๋๋ค(@inkio/editor ์ ์ฉ ๊ธฐ๋ฅ ํ ๊ธ ์ฐธ๊ณ ).
์ปค์คํ ํ์ฅ
extensions prop์ผ๋ก Tiptap ํ์ฅ์ ์ถ๊ฐํ๊ฑฐ๋ ๊ต์ฒดํ ์ ์์ต๋๋ค.
ํ์
type ExtensionsInput =
| Extension[]
| { items: Extension[]; replace?: boolean };- ๋ฐฐ์ด ์ ๋ฌ: ๊ธฐ๋ณธ ํ์ฅ์ ์ถ๊ฐํฉ๋๋ค. ๋์ผํ ์ด๋ฆ์ ํ์ฅ์ด ์์ผ๋ฉด ๊ต์ฒด๋ฉ๋๋ค.
{ items, replace: true }์ ๋ฌ: ๊ธฐ๋ณธ ํ์ฅ์ ์ ๋ถ ๊ต์ฒดํฉ๋๋ค.
์์: ํ์ฅ ์ถ๊ฐ
import { Editor } from '@inkio/editor';
import CharacterCount from '@tiptap/extension-character-count';
<Editor
extensions={[CharacterCount.configure({ limit: 1000 })]}
/>์์: ๊ธฐ๋ณธ ํ์ฅ ์ ์ฒด ๊ต์ฒด
import { Editor } from '@inkio/editor';
import { Document, Paragraph, Text } from '@tiptap/starter-kit';
<Editor
extensions={{ items: [Document, Paragraph, Text], replace: true }}
/>๊ธฐ๋ฅ ํ ๊ธ (@inkio/editor ์ ์ฉ)
@inkio/editor์ Editor ์ปดํฌ๋ํธ๋ ์ฃผ์ ํ์ฅ์ prop์ผ๋ก ์ผ๊ณ ๋ ์ ์์ต๋๋ค.
| Prop | ๊ธฐ๋ณธ๊ฐ | ์ค๋ช |
|---|---|---|
blockHandle | true | ๋ธ๋ก ๋๋๊ทธ ํธ๋ค |
wikiLink | true | [[์ํค๋งํฌ]] ๋ฌธ๋ฒ |
table | true | ํ |
callout | true | ์ฝ์์ ๋ธ๋ก |
toggleList | true | ํ ๊ธ(์ ๊ธฐ/ํผ์น๊ธฐ) ๋ฆฌ์คํธ |
<Editor
blockHandle={false}
wikiLink={false}
/>CSS
@inkio/simple/minimal.css@inkio/editor/minimal.css@inkio/advanced/style.cssโ@inkio/core+@inkio/advanced์ง์ ์กฐํฉ ์@inkio/image-editor/style.css