@liveblocks/react 0.17.7 → 0.17.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.d.ts +8 -0
- package/index.js +42 -0
- package/index.mjs +32 -0
- package/package.json +2 -2
package/index.d.ts
CHANGED
|
@@ -122,6 +122,14 @@ declare type RoomContextBundle<
|
|
|
122
122
|
* It does not impact operations made by other clients.
|
|
123
123
|
*/
|
|
124
124
|
useRedo(): () => void;
|
|
125
|
+
/**
|
|
126
|
+
* Returns whether there are any operations to undo.
|
|
127
|
+
*/
|
|
128
|
+
useCanUndo(): boolean;
|
|
129
|
+
/**
|
|
130
|
+
* Returns whether there are any operations to redo.
|
|
131
|
+
*/
|
|
132
|
+
useCanRedo(): boolean;
|
|
125
133
|
/**
|
|
126
134
|
* Returns the LiveList associated with the provided key.
|
|
127
135
|
* The hook triggers a re-render if the LiveList is updated, however it does not triggers a re-render if a nested CRDT is updated.
|
package/index.js
CHANGED
|
@@ -314,6 +314,48 @@ function createRoomContext(client$1) {
|
|
|
314
314
|
[room]
|
|
315
315
|
);
|
|
316
316
|
},
|
|
317
|
+
useCanRedo: function () {
|
|
318
|
+
var room = useRoom(),
|
|
319
|
+
_React$useState4 = React__namespace.useState(room.history.canRedo),
|
|
320
|
+
canRedo = _React$useState4[0],
|
|
321
|
+
setCanRedo = _React$useState4[1];
|
|
322
|
+
return (
|
|
323
|
+
React__namespace.useEffect(
|
|
324
|
+
function () {
|
|
325
|
+
var unsubscribe = room.subscribe("history", function (_ref2) {
|
|
326
|
+
var canRedo = _ref2.canRedo;
|
|
327
|
+
return setCanRedo(canRedo);
|
|
328
|
+
});
|
|
329
|
+
return function () {
|
|
330
|
+
unsubscribe();
|
|
331
|
+
};
|
|
332
|
+
},
|
|
333
|
+
[room]
|
|
334
|
+
),
|
|
335
|
+
canRedo
|
|
336
|
+
);
|
|
337
|
+
},
|
|
338
|
+
useCanUndo: function () {
|
|
339
|
+
var room = useRoom(),
|
|
340
|
+
_React$useState3 = React__namespace.useState(room.history.canUndo),
|
|
341
|
+
canUndo = _React$useState3[0],
|
|
342
|
+
setCanUndo = _React$useState3[1];
|
|
343
|
+
return (
|
|
344
|
+
React__namespace.useEffect(
|
|
345
|
+
function () {
|
|
346
|
+
var unsubscribe = room.subscribe("history", function (_ref) {
|
|
347
|
+
var canUndo = _ref.canUndo;
|
|
348
|
+
return setCanUndo(canUndo);
|
|
349
|
+
});
|
|
350
|
+
return function () {
|
|
351
|
+
unsubscribe();
|
|
352
|
+
};
|
|
353
|
+
},
|
|
354
|
+
[room]
|
|
355
|
+
),
|
|
356
|
+
canUndo
|
|
357
|
+
);
|
|
358
|
+
},
|
|
317
359
|
useErrorListener: function (callback) {
|
|
318
360
|
var room = useRoom(),
|
|
319
361
|
savedCallback = React__namespace.useRef(callback);
|
package/index.mjs
CHANGED
|
@@ -270,6 +270,38 @@ function createRoomContext(client) {
|
|
|
270
270
|
[room]
|
|
271
271
|
);
|
|
272
272
|
},
|
|
273
|
+
useCanRedo: function () {
|
|
274
|
+
const room = useRoom(),
|
|
275
|
+
[canRedo, setCanRedo] = React.useState(room.history.canRedo);
|
|
276
|
+
return (
|
|
277
|
+
React.useEffect(() => {
|
|
278
|
+
const unsubscribe = room.subscribe(
|
|
279
|
+
"history",
|
|
280
|
+
({ canRedo: canRedo }) => setCanRedo(canRedo)
|
|
281
|
+
);
|
|
282
|
+
return () => {
|
|
283
|
+
unsubscribe();
|
|
284
|
+
};
|
|
285
|
+
}, [room]),
|
|
286
|
+
canRedo
|
|
287
|
+
);
|
|
288
|
+
},
|
|
289
|
+
useCanUndo: function () {
|
|
290
|
+
const room = useRoom(),
|
|
291
|
+
[canUndo, setCanUndo] = React.useState(room.history.canUndo);
|
|
292
|
+
return (
|
|
293
|
+
React.useEffect(() => {
|
|
294
|
+
const unsubscribe = room.subscribe(
|
|
295
|
+
"history",
|
|
296
|
+
({ canUndo: canUndo }) => setCanUndo(canUndo)
|
|
297
|
+
);
|
|
298
|
+
return () => {
|
|
299
|
+
unsubscribe();
|
|
300
|
+
};
|
|
301
|
+
}, [room]),
|
|
302
|
+
canUndo
|
|
303
|
+
);
|
|
304
|
+
},
|
|
273
305
|
useErrorListener: function (callback) {
|
|
274
306
|
const room = useRoom(),
|
|
275
307
|
savedCallback = React.useRef(callback);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@liveblocks/react",
|
|
3
|
-
"version": "0.17.
|
|
3
|
+
"version": "0.17.8",
|
|
4
4
|
"description": "A set of React hooks and providers to use Liveblocks declaratively.",
|
|
5
5
|
"main": "./index.js",
|
|
6
6
|
"module": "./index.mjs",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
},
|
|
18
18
|
"license": "Apache-2.0",
|
|
19
19
|
"peerDependencies": {
|
|
20
|
-
"@liveblocks/client": "0.17.
|
|
20
|
+
"@liveblocks/client": "0.17.8",
|
|
21
21
|
"react": "^16.14.0 || ^17 || ^18"
|
|
22
22
|
},
|
|
23
23
|
"repository": {
|