Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get incorrect delta by Delta.transform #86

Open
weiQuill opened this issue Dec 8, 2022 · 1 comment
Open

Get incorrect delta by Delta.transform #86

weiQuill opened this issue Dec 8, 2022 · 1 comment

Comments

@weiQuill
Copy link

weiQuill commented Dec 8, 2022

Delta package version: 4.2.2

In my use case, the results obtained by Delta.transform were not as expected.

It caused undo doesn't work as expected in the table.
I suspect that in this case, the delete operation was moved to the end causing this issue. Does any have a solution?
Thanks a lot:)

Before undo:
image
After undo:
image

Expected results:
image

Original delta in undo stack

{
  "ops": [
    {
      "retain": 4
    },
    {
      "retain": 1,
      "attributes": {
        "table-cell-line": {
          "row": "row-jj2vxw",
          "cell": "cell-jkfu51"
        },
      }
    },
    {
      "retain": 1,
      "attributes": {
        "table-cell-line": {
          "row": "row-pzu42n",
          "cell": "cell-5s14ao"
        },
      }
    },
    {
      "retain": 1,
      "attributes": {
        "table-cell-line": {
          "row": "row-pzu42n",
          "cell": "cell-oc2pfj"
        },
      }
    },
    {
      "retain": 1,
      "attributes": {
        "table-cell-line": null,
        "row": null,
        "cell": null,
        "rowspan": null,
        "colspan": null
      }
    },
    {
      "delete": 1
    }
  ]
}

delta for remote changes

{
  "ops": [
    {
      "retain": 7
    },
    {
      "insert": "2"
    }
  ]
}

transformed delta in undo stack

{
  "ops": [
    {
      "retain": 4
    },
    {
      "retain": 1,
      "attributes": {
        "table-cell-line": {
          "row": "row-jj2vxw",
          "cell": "cell-jkfu51"
        },
      }
    },
    {
      "retain": 1,
      "attributes": {
        "table-cell-line": {
          "row": "row-pzu42n",
          "cell": "cell-5s14ao"
        },
      }
    },
    {
      "retain": 1,
      "attributes": {
        "table-cell-line": {
          "row": "row-pzu42n",
          "cell": "cell-oc2pfj"
        },
      }
    },
    {
      "retain": 1
    },
    {
      "retain": 1,
      "attributes": {
        "table-cell-line": null,
        "row": null,
        "cell": null,
      }
    },
    {
      "delete": 1
    }
  ]
}
@weiQuill
Copy link
Author

weiQuill commented Dec 8, 2022

I would like to know why the Original delta in undo stack is not:

{
  "ops": [
    {
      "retain": 4
    },
     {
      "delete": 1
     }
  ]
}

I also tested for lines(have no attributes), will got the undoDelta like the above. It looks like my custom attributes are causing the diff calculations to be different.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant