-
-
Notifications
You must be signed in to change notification settings - Fork 120
Closed
Description
hi,
i'm experimenting implementing a richtext editor based on canvas.
my loro doc structrue look like this:
LoroDoc{
body:LoroList[
paragraph:LoroMap{
pPr:{},
text:LoroText
},
table:LoroMap{
tblPr:{},
columns:number[],
rows:LoroList[
row:LoroMap{
rowPr:{},
cells:LoroList[
LoroMap{
cellPr:{},
body:body
}
]
}
]
}
]
}
insert table code:
let table = {
sid: p.sid,
rows,
columns,
} as Tbl;
let lbody = body.lbody as LoroList;
let index = body.blocks.indexOf(p);
tbl2ltable(lbody, table,index + 1);
model.ldoc.commit()
tbl2ltable:
export function tbl2ltable(lbody:LoroList, tbl: Tbl,index) {
let lb = index===-1?lbody.pushContainer(new LoroMap()):lbody.insertContainer(index,new LoroMap);
lb.set("type", "tbl");
let lrows = lb.setContainer("content", new LoroList());
for (let row of tbl.rows) {
let lrow = lrows.pushContainer(new LoroMap());
let lcells = lrow.setContainer("content", new LoroList());
for (let cell of row.cells) {
let lcell = lcells.pushContainer(new LoroMap());
let lbody = lcell.setContainer("content", new LoroList());
body2lbody(cell, lbody);
}
}
}
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?
Metadata
Metadata
Assignees
Labels
No labels