Upgrade to Pro — share decks privately, control downloads, hide ads and more …

目次機能実装から理解するLexical Editor

目次機能実装から理解するLexical Editor

2025.03.19(水) Wantedly Tech Night #9 発表資料

Wantedly Tech Night 〜フロントエンドチームにおける開発文化やツールについて〜
https://wantedly.connpass.com/event/346578

Kyuhwan Lee

March 19, 2025
Tweet

Other Decks in Technology

Transcript

  1. © 2025 Wantedly, Inc. 自己紹介 李 圭煥 (Kyuhwan Lee) @wtdlee

    Wantedly, Inc. (2023/10~) Visit User Growth フロントエンドエンジニア
  2. © 2025 Wantedly, Inc. 目次 • Lexicalについて • Lexicalの基本概念 ◦

    Editor ◦ EditorState ◦ Lexical Nodes ◦ Commands ◦ Editor Plugins • 実際の実装:目次
  3. © 2025 Wantedly, Inc. Lexicalについて • 安定性 ◦ 必要な機能をプラグインとして追加 ◦

    カスタムレンダリングエンジン • アクセシビリティ ◦ Screen Reader ◦ ARIA属性管理 • 性能 ◦ カスタムレンダリングエンジン ◦ JSON基盤の状態管理
  4. © 2025 Wantedly, Inc. Lexicalの設計 • Editor ◦ Lexicalのエンジン ◦

    Lexicalの全体的な動作の処理やイベントを管理 • EditorState ◦ Editor内部の状態(JSON)が記録されているオブジェクト ◦ editor.update()で変更可能
  5. © 2025 Wantedly, Inc. Lexicalの設計 • Lexical Nodes ◦ LexicalのドキュメントはNode基盤

    ◦ 基本Node ▪ TextNode ▪ ParagraphNode ▪ HeadingNode ▪ ListNode, ListItemNode ◦ カスタムNodeの追加でEditor内部の要素として利用可能
  6. © 2025 Wantedly, Inc. Lexicalの設計 • Commands ◦ Editorの特定機能を実行する ◦

    editor.registerCommand()で登録、editor.dispatchCommand()で実行 ◦ createCommandでカスタムコマンドも生成可能 User Action EditorState Command Registry 入力 Command実行 (Editorの状態変更) アップデート View
  7. © 2025 Wantedly, Inc. Lexicalの設計 • Editor Plugins ◦ 特定機能を追加する際に利用可能

    ◦ ex) ▪ RichTextPlugin:Bold, Italicなど基本的な書式 ▪ HistoryPlugin:Undo/Redo ▪ MarkdownShortcutPlugin:Markdown入力 ◦ 目次実装では「TableOfContentsPlugin」を利用
  8. © 2025 Wantedly, Inc. Node.tsx • Serialized Type 定義 ◦

    NodeはClass基盤だが、EditorStateがJSON形式なので NodeもSerializeできる必要がある