lotion icon indicating copy to clipboard operation
lotion copied to clipboard

Set block's unique id for comment and history

Open faridfr opened this issue 2 years ago • 3 comments

Hi, Thanks for your great open-source project 😍. I have a challenge with this editor, maybe you can help me.

I want to set and save the block's unique id in DB for some features like comments or the block's history. Do you have any idea about that? Notice that text or structure changes shouldn't change id.

Thanks.

faridfr avatar Jul 29 '22 13:07 faridfr

To create a history I think that you can use command pattern. https://refactoring.guru/design-patterns/command this way we create less dependency between storing and the features, and can handle this as different and independent features

vitorestevam avatar Jul 29 '22 13:07 vitorestevam

https://github.com/Dashibase/lotion/issues/9 check this talking about history

vitorestevam avatar Jul 29 '22 14:07 vitorestevam

Thanks, but i don't mean real-time history or browser history, I want to save comments and text changes history in the database and I need unique if for blocks.

faridfr avatar Jul 29 '22 14:07 faridfr

If I understand @faridfr correctly, what you are essentially requesting is for lotion to include a unique id in the blocks right?

For example,

current json

  {
    "type": "H1",
    "details": {
      "value": "Get Started"
    }
  },
  {
    "type": "DIVIDER",
    "details": {}
  },
  {
    "type": "TEXT",
    "details": {
      "value": "👋 Welcome! This is a private page for you to play around with."
    }
  },

to be updated to something like

  {
    "id": "uniqueId1",
    "type": "H1",
    "details": {
      "value": "Get Started"
    }
  },
  {
    "id": "uniqueId2",
    "type": "DIVIDER",
    "details": {}
  },
  {
    "id": "uniqueId3",
    "type": "TEXT",
    "details": {
      "value": "👋 Welcome! This is a private page for you to play around with."
    }
  },

lyqht avatar Aug 03 '22 12:08 lyqht

Exactly @lyqht , Of course, we must be aware that the changes on the blocks should not change their ID, because of losing comments and other features on the blocks.

faridfr avatar Aug 03 '22 19:08 faridfr