Skip to Content
์ปดํฌ๋„ŒํŠธ

์ปดํฌ๋„ŒํŠธ

๊ณตํ†ต UI ๊ณ„์•ฝ

@inkio/editor UI ์ปดํฌ๋„ŒํŠธ๋Š” ๊ณตํ†ต์œผ๋กœ ์•„๋ž˜ override๋ฅผ ์ง€์›ํ•ฉ๋‹ˆ๋‹ค.

  • locale?: unknown
  • messages?: InkioMessageOverrides (๋˜๋Š” core ์ „์šฉ partial)
  • icons?: Partial<InkioIconRegistry>

๊ถŒ์žฅ ํŒจํ„ด์€ ํ•œ ๋ฒˆ ์ •์˜ํ•œ ๊ฐ’์„ Editor, CommentPanel, CommentComposer, ImageEditorModal, getDefaultInkioExtensions()์— ๋™์ผํ•˜๊ฒŒ ์ „๋‹ฌํ•˜๋Š” ๊ฒƒ์ž…๋‹ˆ๋‹ค.

import { Editor, inkioIconRegistry, type InkioMessageOverrides, } from '@inkio/editor'; import { getDefaultInkioExtensions } from '@inkio/extension'; const locale = 'en-US,en;q=0.9'; const messages: InkioMessageOverrides = { core: { suggestion: { empty: 'No matching items.' }, }, extensions: { commentComposer: { placeholder: 'Share feedback...' }, }, }; const icons = { comment: inkioIconRegistry.comment, }; const extensions = getDefaultInkioExtensions({ blockHandle: true, locale, messages, icons, }); <Editor extensions={extensions} locale={locale} messages={messages} icons={icons} showBubbleMenu showFloatingMenu />

์ด ์˜ˆ์ œ๋Š” override ์ „๋‹ฌ ํŒจํ„ด์„ ๋ณด์—ฌ์ฃผ๊ธฐ ์œ„ํ•ด full preset์„ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค. ์‹œ์ž‘์ ์ด๋‚˜ ๋ฒˆ๋“ค ์ตœ์ ํ™”๊ฐ€ ์ค‘์š”ํ•˜๋ฉด getDefaultCoreExtensions()์™€ ํ•„์š”ํ•œ extension ์„œ๋ธŒํŒจ์Šค import๋ฅผ ์ง์ ‘ ์กฐํ•ฉํ•˜๋Š” ์ชฝ์ด ๋” ์ ํ•ฉํ•ฉ๋‹ˆ๋‹ค.

@inkio/editor

Editor

PropTypeDescription
contentstring | JSONContentcontrolled ์ฝ˜ํ…์ธ 
initialContentstring | JSONContentuncontrolled ์ดˆ๊ธฐ๊ฐ’
extensionsExtensions์ ์šฉํ•  ํ™•์žฅ ๋ชฉ๋ก
editablebooleanํŽธ์ง‘ ๊ฐ€๋Šฅ ์—ฌ๋ถ€
onUpdate(content: JSONContent) => void๋ณ€๊ฒฝ ์ฝœ๋ฐฑ
onCreate(editor: Editor) => void์ƒ์„ฑ ์ฝœ๋ฐฑ
classNamestring์—๋””ํ„ฐ ์ฝ˜ํ…์ธ  ํด๋ž˜์Šค
styleReact.CSSProperties์ปจํ…Œ์ด๋„ˆ ์Šคํƒ€์ผ
unstyledboolean๊ธฐ๋ณธ ์ปจํ…Œ์ด๋„ˆ ์Šคํƒ€์ผ(minHeight, padding ๋“ฑ inline CSS) ๋น„ํ™œ์„ฑํ™”
showBubbleMenubooleanํ…์ŠคํŠธ ์„ ํƒ ์‹œ BubbleMenu ํ‘œ์‹œ ์—ฌ๋ถ€
showFloatingMenuboolean๋นˆ ์ค„์— FloatingMenu ํ‘œ์‹œ ์—ฌ๋ถ€
localeunknownlocale ์ž…๋ ฅ
messagesInkioMessageOverrides๋ฉ”์‹œ์ง€ override
iconsPartial<InkioIconRegistry>์•„์ด์ฝ˜ override

์Šคํƒ€์ผ๋ง ์•„ํ‚คํ…์ฒ˜ (Styling Architecture)

Inkio๋Š” ์œ ์—ฐํ•œ ์Šคํƒ€์ผ๋ง์„ ์œ„ํ•ด CSS์™€ Inline Style์„ ๊ตฌ๋ถ„ํ•˜์—ฌ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค.

  1. ๋‚ด์žฅ CSS (Built-in CSS):

    • @inkio/editor/style.css: ํƒ€์ดํฌ๊ทธ๋ž˜ํ”ผ, ๋งˆํฌ๋‹ค์šด ์š”์†Œ(p, h1, blockquote), ๊ธฐ๋ณธ ํ† ํฐ ๋ณ€์ˆ˜๊ฐ€ ๋ชจ๋‘ ํฌํ•จ๋œ ์™„์ „ํ•œ ์Šคํƒ€์ผ์ž…๋‹ˆ๋‹ค.
    • @inkio/editor/minimal.css: ํ•ต์‹ฌ ์—๋””ํ„ฐ ๋™์ž‘๊ณผ ํ”Œ๋กœํŒ… ๋ฉ”๋‰ด ๋“ฑ ํ•„์ˆ˜ ๋ ˆ์ด์•„์›ƒ๋งŒ ํฌํ•จ๋˜์–ด ์žˆ์œผ๋ฉฐ ํฐํŠธ ๋””์ž์ธ์€ ์ œ์™ธ๋ฉ๋‹ˆ๋‹ค.
    • ํ˜ธ์ŠคํŠธ ์•ฑ์€ ์ด CSS ํŒŒ์ผ๋“ค์„ import ํ•˜์—ฌ ๋ฌธ์„œ ๋””์ž์ธ์„ ์†์‰ฝ๊ฒŒ ์™„์„ฑํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
  2. unstyled Prop์˜ ์—ญํ• :

    • <Editor>์™€ <Viewer>๋Š” ๊ธฐ๋ณธ์ ์œผ๋กœ ์—๋””ํ„ฐ ์˜์—ญ ํ™•๋ณด๋ฅผ ์œ„ํ•ด ์ธ๋ผ์ธ ์Šคํƒ€์ผ(minHeight: 200px, cursor: text ๋“ฑ)์„ ์ฃผ์ž…ํ•ฉ๋‹ˆ๋‹ค.
    • unstyled={true}๋ฅผ ์ „๋‹ฌํ•˜๋ฉด ์ด๋Ÿฌํ•œ ์ปดํฌ๋„ŒํŠธ ์ธ๋ผ์ธ ์Šคํƒ€์ผ์ด ์™„์ „ํžˆ ์ œ๊ฑฐ๋ฉ๋‹ˆ๋‹ค. ์ฆ‰, CSS ํŒŒ์ผ ๋กœ๋“œ ์—ฌ๋ถ€์™€ ์ƒ๊ด€์—†์ด ์ปจํ…Œ์ด๋„ˆ์˜ ํฌ๊ธฐ๋ฅผ 100% ์ปค์Šคํ…€ํ•˜๊ณ  ์‹ถ์„ ๋•Œ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค.
  3. ์‚ฌ์šฉ์ž ์ •์˜ (Host App Customization):

    • ํฐํŠธ ์ข…๋ฅ˜(font-family), ๋‹คํฌ ๋ชจ๋“œ ํ† ๊ธ€ ์ฒด๊ณ„(data-theme="dark"), ์—๋””ํ„ฐ ์™ธ๋ถ€ ๋ ˆ์ด์•„์›ƒ์€ ์ „์ ์œผ๋กœ ์‚ฌ์šฉ์ž๊ฐ€ ์ œ์–ดํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. (๋””์ž์ธ ํ† ํฐ ์˜ค๋ฒ„๋ผ์ด๋“œ ๋ฐฉ์‹ ๊ถŒ์žฅ)

Viewer

์ฝ๊ธฐ ์ „์šฉ ์ปดํฌ๋„ŒํŠธ์ž…๋‹ˆ๋‹ค.

BubbleMenu / FloatingMenu

๊ฐ UI ์ปดํฌ๋„ŒํŠธ๋Š” locale/messages/icons override๋ฅผ ์ง์ ‘ ๋ฐ›์„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

๋‹จ์ผ ๋ ˆ์ง€์ŠคํŠธ๋ฆฌ

ํˆด๋ฐ”/๋ฒ„๋ธ”/ํ”Œ๋กœํŒ… ๋ฉ”๋‰ด ์•ก์…˜์€ ํ•˜๋‚˜์˜ ์Šคํ‚ค๋งˆ๋กœ ๊ด€๋ฆฌ๋ฉ๋‹ˆ๋‹ค.

import { inkioToolbarSchema, inkioIconRegistry, type InkioToolbarActionId, type InkioIconId, } from '@inkio/editor';
  • inkioToolbarSchema: ์•ก์…˜ ์ •์˜(ํ‘œ์‹œ surface, ์‹คํ–‰ command, ๊ทธ๋ฃน)
  • inkioIconRegistry: ์•ก์…˜ ์•„์ด์ฝ˜ ๋งต
  • InkioToolbarActionId, InkioIconId: ํƒ€์ž… ์•ˆ์ „ํ•œ ID

i18n ๊ธฐ๋ณธ ๋ฉ”์‹œ์ง€

๊ธฐ๋ณธ ๋‚ด์žฅ ๋ฉ”์‹œ์ง€๋Š” ์˜์–ด๋งŒ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค.

import { enCoreMessages } from '@inkio/editor'; import { enExtensionsMessages } from '@inkio/extension';

๋‹ค๊ตญ์–ด๋Š” ์†Œ๋น„์ž๊ฐ€ messages prop์œผ๋กœ ์ฃผ์ž…ํ•˜๋Š” ๋ฐฉ์‹์ž…๋‹ˆ๋‹ค.

@inkio/extension

๋‹ค์Œ ํ™•์žฅ์„ ๋ฃจํŠธ ๋˜๋Š” ์„œ๋ธŒํŒจ์Šค๋กœ importํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

  • Mention (@inkio/extension/mention)
  • HashTag (@inkio/extension/hashtag)
  • SlashCommand (@inkio/extension/slash-command)
  • WikiLink (@inkio/extension/wikilink)
  • Callout (@inkio/extension/callout)
  • BlockHandle, BlockHandleActionMenu (@inkio/extension/block-handle)
  • Comment, CommentPanel, CommentComposer (@inkio/extension/comment)
  • ImageEditorModal, ImageEditor (@inkio/extension/image)

๋ ˆ๊ฑฐ์‹œ CommentSidebar, CommentPopover export๋Š” ์ œ๊ฑฐ๋˜์—ˆ์Šต๋‹ˆ๋‹ค.

Last updated on