delta icon indicating copy to clipboard operation
delta copied to clipboard

Looking for Suggestions - Need to Store JSON delta's with linebreak mid sentence as multiple delta's

Open alilland opened this issue 5 months ago • 0 comments

I've been using delta/quilljs for about 7 months now, so much of my application is leaning on it pretty heavily at this point.

I am working on a feature where I cannot have linebreaks mid word, i need them to be split out into multiple delta's

{
    "ops": [
        {
            "insert": "Abraham the Man of Faith"
        },
        {
            "attributes": {
                "header": 3
            },
            "insert": "\n"
        },
        {
            "insert": "In many ways, the Binding of Isaac in Genesis 22 is the climax of Abrahams life. It constitutes the greatest test and crescendo for Abraham (and "
        },
        {
            "attributes": {
                "italic": true
            },
            "insert": "Isaac"
        },
        {
            "insert": ").\n\nContext"
        },
        {
            "attributes": {
                "header": 4
            },
            "insert": "\n"
        },
        {
            "insert": "Abraham had two sons, Ishmael and Isaac - we know that it was because Abraham disbelieved God that he had Ishmael by means of Hagar, which was his wife Sarah's maidservant.\n\n"
        },
        {
            "insert": {
                "image": "https://api.steppingstonesintl.com/v1/images/59f38f96-c323-45b2-8ea8-326485d98d4f/binding-of-isaac.webp"
            }
        }
    ]
}

the following two delta's represent a header, and the ending of the sentence above the header

{
  "insert": ").\n\nContext"
},
{
  "attributes": {
      "header": 4
  },
"insert": "\n"
},

i need to re-parse my delta structure to ensure that the <h4>Context</h4> element is its own delta

anyone ever come across a library that does this?

alilland avatar Aug 26 '24 23:08 alilland