Direkt zum Hauptinhalt

In Depth: Editor CRDT

Work in Progress! CRDT isn't implemented yet.

Ablauf:

  1. Client möchte Kapitel bearbeiten, Client öffnet web socket mit Server
  2. Client bekommt yDoc von Server
  3. Client wandelt yDoc Änderungen in EditorJS Blockänderungen um <-- Herausforderung 1
  4. Bei Änderungen an Blöcken wird änderung in yDoc Änderung umgewandelt <-- Herausforderung 2
  5. yDoc Änderung wird an Server geschickt
  6. Server schickt yDoc Änderung an alle anderen Clients

Beispiel EditorJS Block JSON:

  {
    "id": "jaJh1uNPLq",
    "type": "paragraph",
    "data": {
      "text": "In the spring of 2024, video cameras from numerous global news outlets turned their attention to a court in Strasbourg. People traveled from across Europe, gathering with signs in front of the courthouse. Minors from Portugal stood alongside senior citizens from Switzerland to witness one of the most significant moments in the recent history of the European Convention on Human Rights. For the first time, the European Court of Human Rights (ECtHR) ruled on the impact of the climate crisis on human rights and what this means for the Convention’s signatory states. The court’s Grand Chamber issued rulings on three cases: the case of <i>Carême v. France</i><citation data-key=\"ECtHR_careme_2024\">C</citation> (“<i>Carême</i>”), brought by the former mayor of Grande-Synthe, France; the case of <i>Duarte Agostinho and Others v. Portugal and 32 Others</i><citation data-key=\"ECtHR_duarte_2024\">C</citation>&nbsp;(“<i>Duarte Agostinho</i>”), brought by six youth applicants from Portugal; and the case of <i>Verein KlimaSeniorinnen Schweiz and Others v. Switzerland</i><citation data-key=\"noauthor_hudoc_nodate\">C</citation><i>&nbsp;</i>(“<i>KlimaSeniorinnen</i>”). While the first two cases were deemed inadmissible, the court handed down a ruling in <i>Klimaseniorinnen</i>, which is already regarded as one of the most important judgments in climate change litigation. The court stated that “the state has a positive duty to adopt, and effectively implement in practice, regulations and measures capable of mitigating the existing and potentially irreversible future effects of climate change”. Regarding the Swiss government, one of the Convention’s signatory states, the court concluded that by failing to put in place a sufficient domestic regulatory framework for climate change mitigation, the government violated Article 8 of the European Convention on Human Rights (ECHR), the right to respect for private and family life. Article 8 requires “that each Contracting State undertake measures for the substantial and progressive reduction of their respective GHG emission levels, with a view to reaching net neutrality within, in principle, the next three decades” (<i>KlimaSeniorinnen</i>, para. 548). Moreover, the Court found a violation of the right of access to court (Article 6 of the ECHR). "
    },
    "tunes": {}
  },
  {
    "id": "M29CgX78Fc",
    "type": "header",
    "data": {
      "text": "The three climate rulings",
      "level": 1
    },
    "tunes": {}
  },

EditorJS hat eine insert Funktion, über die können wir Blöcke dann einfügen: https://editorjs.io/blocks/#insert

Wir müssen ein äquivalent in yrs Typen schaffen, tunes brauchen wir nicht, id's vermutlich auch nicht (?). Data muss eine map sein und hat neben text optionale andere einträge

Protokoll

Clients und Server kommunizieren über Websockets miteinander. Das erste Byte jeder Nachricht bestimmt den Nachrichtentyp:

1st Byte Decimal Value Name Binary / JSON? Sent from Data Description
10 CONNECT JSON Client session_id, document_id Connect to server with existing session and edit document with document_id
11 WELCOME JSON Server client_id todo
20 GETDOC Binary Client StateVector todo
21 DOCUPDATE Binary Server Document update todo
30 UPDATEDOC Binary Client / Server Document update todo
40 SETCURSOR JSON Client/Server client_id, block_id, start, end (optional, only for selections) todo
41 REMOVECURSOR JSON Server client_id todo
50 DISCONNECT JSON Client client_id todo
60 ERROR JSON Server status_code, error_msg error occured, e.g. authorization failed due to invalid session_id, document not found etc.