@jucie.io/state 1.0.36 → 1.0.38
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/LICENSE +61 -0
- package/README.md +9 -9
- package/dist/State.js +170 -209
- package/dist/lib/array.js +23 -6
- package/dist/lib/change.js +4 -0
- package/dist/lib/gsru.js +33 -9
- package/dist/lib/marker.js +42 -8
- package/dist/lib/pathEncoder.js +8 -0
- package/dist/lib/query/canonicalQuery.js +21 -0
- package/dist/lib/query/isMatch.js +5 -0
- package/dist/lib/query/isQuerySegment.js +5 -0
- package/dist/lib/reportedAs.js +5 -0
- package/dist/lib/tree/resolveChunks.js +46 -0
- package/dist/lib/tree/traverseChunks.js +29 -0
- package/dist/main.js +4 -4
- package/dist/main.js.map +4 -4
- package/package.json +3 -2
- package/plugins/history/README.md +11 -9
|
@@ -217,13 +217,13 @@ const state = createState({
|
|
|
217
217
|
|
|
218
218
|
// Install with custom configuration
|
|
219
219
|
state.install(HistoryManager.configure({
|
|
220
|
-
maxSize: 200 //
|
|
220
|
+
maxSize: 200 // Keep up to 200 undo steps (default: 100)
|
|
221
221
|
}));
|
|
222
222
|
```
|
|
223
223
|
|
|
224
224
|
### Options
|
|
225
225
|
|
|
226
|
-
- **`maxSize`** (number): Maximum number of
|
|
226
|
+
- **`maxSize`** (number): Maximum number of undo steps to keep. A step is one commit, however many changes it holds; the oldest step is dropped whole. Default: `100`
|
|
227
227
|
|
|
228
228
|
## Advanced Usage
|
|
229
229
|
|
|
@@ -243,15 +243,17 @@ state.history.commit();
|
|
|
243
243
|
// All changes are now a single undo step with a descriptive marker
|
|
244
244
|
```
|
|
245
245
|
|
|
246
|
-
###
|
|
246
|
+
### Untracked Writes
|
|
247
247
|
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
state.set(['temp', 'data'], 'not recorded');
|
|
248
|
+
Writes inside `untracked` stay in state but never become an undo step — for
|
|
249
|
+
shared data (comments, presence) that one user's undo must not take back. The
|
|
250
|
+
callback must be synchronous: writes after an `await` are recorded. It returns
|
|
251
|
+
what the callback returns.
|
|
253
252
|
|
|
254
|
-
|
|
253
|
+
```javascript
|
|
254
|
+
state.history.untracked(() => {
|
|
255
|
+
state.set(['comments', 'c1'], { text: 'not recorded' });
|
|
256
|
+
});
|
|
255
257
|
|
|
256
258
|
state.set(['tracked', 'data'], 'recorded'); // This will be recorded
|
|
257
259
|
```
|