how to design/insert a table without too many events #869
Replies: 5 comments
-
How to capture only main events in LoroDoc?To capture only the main events, such as inserting a table ( Here's how you can achieve this:
Here's an example of how you might implement this: const doc = new LoroDoc();
doc.subscribe((event) => {
if (event.origin === 'mainEvent') {
console.log("Main Event:", event);
}
});
const body = doc.getList("body");
const table = new LoroMap();
body.push(table);
// Commit the previous transaction and start a new one
doc.commit();
table.set("tblPr", {});
table.set("columns", []);
table.set("rows", new LoroList());
doc.commit({ origin: 'mainEvent' }); // Commit with an origin identifierBy using transactions and setting an origin identifier, you can effectively capture only the main events and ignore the child events in your |
Beta Was this translation helpful? Give feedback.
-
|
in ts: |
Beta Was this translation helpful? Give feedback.
-
|
Oh, it should be doc.commit() directly. Updated. |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.

Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
hi,
i'm experimenting implementing a richtext editor based on canvas.
my loro doc structrue look like this:
insert table code:
tbl2ltable:
my problem is when inserting a new table, too many events in subscribe call back.
what i want is only captureing the main event: inserting table(LoroMap) and ignore the other child events.
how to achieve this?
Beta Was this translation helpful? Give feedback.
All reactions