Skip to content

Commit db5902c

Browse files
authored
refactor(superdoc): cast doc.ydoc in setLocked (SD-2867 phase B) (#3066)
* refactor(superdoc): type three implicit-any locals (SD-2867 phase B) * refactor(superdoc): type four implicit-any params (SD-2867 phase B) * refactor(superdoc): cast doc.ydoc in setLocked (SD-2867 phase B)
1 parent 4641084 commit db5902c

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

packages/superdoc/src/core/SuperDoc.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1517,8 +1517,13 @@ export class SuperDoc extends EventEmitter {
15171517
*/
15181518
setLocked(lock = true) {
15191519
this.config.documents.forEach((doc) => {
1520-
const metaMap = doc.ydoc.getMap('meta');
1521-
doc.ydoc.transact(() => {
1520+
// setLocked is a collaboration-only API; the surrounding flow only
1521+
// calls it once each document has a Yjs doc attached. Cast away the
1522+
// optional shape on the public Document typedef without changing
1523+
// runtime behavior.
1524+
const ydoc = /** @type {import('yjs').Doc} */ (doc.ydoc);
1525+
const metaMap = ydoc.getMap('meta');
1526+
ydoc.transact(() => {
15221527
metaMap.set('locked', lock);
15231528
metaMap.set('lockedBy', this.user);
15241529
});

0 commit comments

Comments
 (0)