0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

【Draft.js】Entity

Posted at

Entityとは

  • ContentBlocktext のメタデータを表す要素
  • ContentStateentityMap にエンティティの数分格納されている

Entityに格納される情報

type

  • どのような種類のエンティティであるか
    • デフォルトで用意されている type は下記の通り
      • LINK
      • TOKEN
      • PHOTO
      • IMAGE
    • 上記以外に自作の type も定義可能
  • type に対してレンダリングするReactコンポーネントを指定可能

mutability

  • エンティティオブジェクトでアノテーションされたテキストの範囲をエディタ内で編集する際の動作を示す
    • 下記の3つを指定可能
      • MUTABLE
        text からエンティティアノテーションを削除しなければ編集不可
        (例) 画像、メンション
      • IMMUTABLE
        text を自由に編集可能
        (例) テキストリンク
      • SEGMENTED
        基本的には IMMUTABLE と同じだが、削除時の挙動をカスタマイズ可能

data

  • エンティティのメタデータ
    (例) LINK エンティティの場合、a タグの href に渡すurlを持つ
    { url: "https://example.com" }
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?