@ablogcms/block-editor
v3.2.28-beta.0
Published
Tiptap ベースのブロックエディタ
Keywords
Readme
@ablogcms/block-editor
Tiptap ベースのブロックエディタ。エントリー本文編集の主要 UI で、テーブル・画像ブロック・貼り付け ハンドリングなどの拡張を含む。
使い方
import { BlockEditor, normalizeSettings, DEFAULT_EDITOR_SETTINGS } from '@ablogcms/block-editor';
const settings = normalizeSettings(rawSettingsFromServer);
<BlockEditor editorSettings={settings ?? DEFAULT_EDITOR_SETTINGS} onUpdate={(html) => console.log(html)} />;editorSettings: 機能フラグ・ブロックメニュー・フォントサイズ・カラーパレットなどの設定 (EditorSettings)。このパッケージ自体はデータ取得を行わないため、呼び出し側が取得して渡す。onUpdate(html): 本文が変更されるたびに、シリアライズ後の HTML 文字列を渡して呼ばれる。settings: エディター個別の宣言的な上書き設定(allow/deny/blocksなど)。normalizeSettings(raw): サーバーの生レスポンスをEditorSettingsに変換する純粋関数。SettingsProvider/useSettingsContext:EditorSettingsをツリーの深い位置まで配る Context。
