@lexical/utils 0.32.2-nightly.20250619.0 → 0.32.2-nightly.20250623.0

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.
@@ -17,6 +17,8 @@ import type {
17
17
  RootMode,
18
18
  SplitAtPointCaretNextOptions,
19
19
  PointCaret,
20
+ StateConfig,
21
+ ValueOrUpdater
20
22
  } from 'lexical';
21
23
  declare export function addClassNamesToElement(
22
24
  element: HTMLElement,
@@ -174,3 +176,49 @@ declare export function $getAdjacentSiblingOrParentSiblingCaret<
174
176
  startCaret: NodeCaret<D>,
175
177
  rootMode?: RootMode,
176
178
  ): null | [NodeCaret<D>, number];
179
+
180
+ export type StateConfigWrapper<K: string, V> = {
181
+ +stateConfig: StateConfig<K, V>;
182
+ +$get: <T: LexicalNode>(node: T) => V;
183
+ +$set: <T: LexicalNode>(
184
+ node: T,
185
+ valueOrUpdater: ValueOrUpdater<V>,
186
+ ) => T;
187
+ /** `[$get, $set]` */
188
+ +accessors: $ReadOnly<[$get: StateConfigWrapper<K, V>['$get'], $set: StateConfigWrapper<K, V>['$set']]>;
189
+ /**
190
+ * `() => function () { return $get(this) }`
191
+ *
192
+ * Should be called with an explicit `this` type parameter.
193
+ *
194
+ * @example
195
+ * ```ts
196
+ * class MyNode {
197
+ * // …
198
+ * myGetter = myWrapper.makeGetterMethod<this>();
199
+ * }
200
+ * ```
201
+ */
202
+ makeGetterMethod<T: LexicalNode>(): (this: T) => V;
203
+ /**
204
+ * `() => function (valueOrUpdater) { return $set(this, valueOrUpdater) }`
205
+ *
206
+ * Must be called with an explicit `this` type parameter.
207
+ *
208
+ * @example
209
+ * ```ts
210
+ * class MyNode {
211
+ * // …
212
+ * mySetter = myWrapper.makeSetterMethod<this>();
213
+ * }
214
+ * ```
215
+ */
216
+ makeSetterMethod<T: LexicalNode>(): (
217
+ this: T,
218
+ valueOrUpdater: ValueOrUpdater<V>,
219
+ ) => T;
220
+ };
221
+
222
+ declare export function makeStateWrapper<K: string, V>(
223
+ stateConfig: StateConfig<K, V>,
224
+ ): StateConfigWrapper<K, V>;
package/package.json CHANGED
@@ -8,14 +8,14 @@
8
8
  "utils"
9
9
  ],
10
10
  "license": "MIT",
11
- "version": "0.32.2-nightly.20250619.0",
11
+ "version": "0.32.2-nightly.20250623.0",
12
12
  "main": "LexicalUtils.js",
13
13
  "types": "index.d.ts",
14
14
  "dependencies": {
15
- "@lexical/list": "0.32.2-nightly.20250619.0",
16
- "@lexical/selection": "0.32.2-nightly.20250619.0",
17
- "@lexical/table": "0.32.2-nightly.20250619.0",
18
- "lexical": "0.32.2-nightly.20250619.0"
15
+ "@lexical/list": "0.32.2-nightly.20250623.0",
16
+ "@lexical/selection": "0.32.2-nightly.20250623.0",
17
+ "@lexical/table": "0.32.2-nightly.20250623.0",
18
+ "lexical": "0.32.2-nightly.20250623.0"
19
19
  },
20
20
  "repository": {
21
21
  "type": "git",