B
B
balex7772022-02-15 14:51:53
React
balex777, 2022-02-15 14:51:53

How to get text from saved _immutable Draft js object?

Hello, in the database I save the text from Draft js in this form.

How can I get text from this object in any place I need?

{
  "_immutable": {
    "allowUndo": true,
    "currentContent": {
      "entityMap": {},
      "blockMap": {
        "32roc": {
          "key": "32roc",
          "type": "unstyled",
          "text": "ощгрищшгр шщорщ",
          "characterList": [
            {
              "style": [],
              "entity": null
            },
            {
              "style": [],
              "entity": null
            },
            {
              "style": [],
              "entity": null
            },
            {
              "style": [],
              "entity": null
            },
            {
              "style": [],
              "entity": null
            },
            {
              "style": [],
              "entity": null
            },
            {
              "style": [],
              "entity": null
            },
            {
              "style": [],
              "entity": null
            },
            {
              "style": [],
              "entity": null
            },
            {
              "style": [],
              "entity": null
            },
            {
              "style": [],
              "entity": null
            },
            {
              "style": [],
              "entity": null
            },
            {
              "style": [],
              "entity": null
            },
            {
              "style": [],
              "entity": null
            },
            {
              "style": [],
              "entity": null
            }
          ],
          "depth": 0,
          "data": {}
        }
      },
      "selectionBefore": {
        "anchorKey": "32roc",
        "anchorOffset": 0,
        "focusKey": "32roc",
        "focusOffset": 0,
        "isBackward": false,
        "hasFocus": true
      },
      "selectionAfter": {
        "anchorKey": "32roc",
        "anchorOffset": 15,
        "focusKey": "32roc",
        "focusOffset": 15,
        "isBackward": false,
        "hasFocus": true
      }
    },
    "decorator": {
      "_decorators": [
        {}
      ]
    },
    "directionMap": {
      "32roc": "LTR"
    },
    "forceSelection": false,
    "inCompositionMode": false,
    "inlineStyleOverride": null,
    "lastChangeType": "insert-characters",
    "nativelyRenderedContent": null,
    "redoStack": [],
    "selection": {
      "anchorKey": "32roc",
      "anchorOffset": 15,
      "focusKey": "32roc",
      "focusOffset": 15,
      "isBackward": false,
      "hasFocus": false
    },
    "treeMap": {
      "32roc": [
        {
          "start": 0,
          "end": 15,
          "decoratorKey": null,
          "leaves": [
            {
              "start": 0,
              "end": 15
            }
          ]
        }
      ]
    },
    "undoStack": [
      {
        "entityMap": {},
        "blockMap": {
          "32roc": {
            "key": "32roc",
            "type": "unstyled",
            "text": "",
            "characterList": [],
            "depth": 0,
            "data": {}
          }
        },
        "selectionBefore": {
          "anchorKey": "32roc",
          "anchorOffset": 0,
          "focusKey": "32roc",
          "focusOffset": 0,
          "isBackward": false,
          "hasFocus": false
        },
        "selectionAfter": {
          "anchorKey": "32roc",
          "anchorOffset": 0,
          "focusKey": "32roc",
          "focusOffset": 0,
          "isBackward": false,
          "hasFocus": false
        }
      }
    ]
  }
}

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question