@lexical/html 0.43.1-nightly.20260417.0 → 0.44.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.
- package/ContextRecord.d.ts +93 -0
- package/DOMRenderExtension.d.ts +16 -0
- package/LexicalHtml.dev.js +650 -50
- package/LexicalHtml.dev.mjs +638 -49
- package/LexicalHtml.js.flow +178 -11
- package/LexicalHtml.mjs +12 -1
- package/LexicalHtml.node.mjs +12 -1
- package/LexicalHtml.prod.js +1 -1
- package/LexicalHtml.prod.mjs +1 -1
- package/RenderContext.d.ts +32 -0
- package/compileDOMRenderConfigOverrides.d.ts +22 -0
- package/constants.d.ts +10 -0
- package/domOverride.d.ts +18 -0
- package/index.d.ts +17 -0
- package/package.json +5 -4
- package/types.d.ts +293 -0
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
import type { AnyContextConfigPairOrUpdater, AnyContextSymbol, ContextConfig, ContextConfigPair, ContextConfigUpdater, ContextRecord } from './types';
|
|
9
|
+
import { type LexicalEditor } from 'lexical';
|
|
10
|
+
type WithContext<Ctx extends AnyContextSymbol> = {
|
|
11
|
+
[K in Ctx]?: undefined | ContextRecord<Ctx>;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* @experimental
|
|
15
|
+
*
|
|
16
|
+
* The LexicalEditor with context
|
|
17
|
+
*/
|
|
18
|
+
export type EditorContext = {
|
|
19
|
+
editor: LexicalEditor;
|
|
20
|
+
} & WithContext<AnyContextSymbol>;
|
|
21
|
+
/**
|
|
22
|
+
* @experimental
|
|
23
|
+
*
|
|
24
|
+
* @param contextRecord The ContextRecord
|
|
25
|
+
* @param cfg The configuration
|
|
26
|
+
* @returns The value or defaultValue of cfg
|
|
27
|
+
*/
|
|
28
|
+
export declare function getContextValue<Ctx extends AnyContextSymbol, V>(contextRecord: undefined | ContextRecord<Ctx>, cfg: ContextConfig<Ctx, V>): V;
|
|
29
|
+
/**
|
|
30
|
+
* @experimental
|
|
31
|
+
*
|
|
32
|
+
* Read and delete cfg from this layer of context
|
|
33
|
+
*
|
|
34
|
+
* @param contextRecord The ContextRecord
|
|
35
|
+
* @param cfg The configuration
|
|
36
|
+
* @returns The value of the configuration that was removed
|
|
37
|
+
*/
|
|
38
|
+
export declare function popOwnContextValue<Ctx extends AnyContextSymbol, V>(contextRecord: ContextRecord<Ctx>, cfg: ContextConfig<Ctx, V>): undefined | V;
|
|
39
|
+
/**
|
|
40
|
+
* @experimental
|
|
41
|
+
*
|
|
42
|
+
* Get the value without a default
|
|
43
|
+
*
|
|
44
|
+
* @param contextRecord The ContextRecord
|
|
45
|
+
* @param cfg The configuration
|
|
46
|
+
* @returns The current value in this context or `undefined` if not set
|
|
47
|
+
*/
|
|
48
|
+
export declare function getOwnContextValue<Ctx extends AnyContextSymbol, V>(contextRecord: ContextRecord<Ctx>, cfg: ContextConfig<Ctx, V>): undefined | V;
|
|
49
|
+
/**
|
|
50
|
+
* @experimental
|
|
51
|
+
*
|
|
52
|
+
* @param sym The symbol for this ContextRecord (e.g. DOMRenderContextSymbol)
|
|
53
|
+
* @param editor The editor
|
|
54
|
+
* @returns The current context or undefined
|
|
55
|
+
*/
|
|
56
|
+
export declare function getContextRecord<Ctx extends AnyContextSymbol>(sym: Ctx, editor: LexicalEditor): undefined | ContextRecord<Ctx>;
|
|
57
|
+
/**
|
|
58
|
+
* Construct a new context from a parent context and pairs
|
|
59
|
+
*
|
|
60
|
+
* @param pairs The pairs and updaters to build the context from
|
|
61
|
+
* @param parent The parent context
|
|
62
|
+
* @returns The new context
|
|
63
|
+
*/
|
|
64
|
+
export declare function contextFromPairs<Ctx extends AnyContextSymbol>(pairs: readonly AnyContextConfigPairOrUpdater<Ctx>[], parent: undefined | ContextRecord<Ctx>): undefined | ContextRecord<Ctx>;
|
|
65
|
+
/**
|
|
66
|
+
* Create a context config pair that sets a value in the render context.
|
|
67
|
+
* @experimental
|
|
68
|
+
*/
|
|
69
|
+
export declare function contextValue<Ctx extends AnyContextSymbol, V>(cfg: ContextConfig<Ctx, V>, value: V): ContextConfigPair<Ctx, V>;
|
|
70
|
+
/**
|
|
71
|
+
* Create a context config updater that transforms a value in the render context.
|
|
72
|
+
* @experimental
|
|
73
|
+
*/
|
|
74
|
+
export declare function contextUpdater<Ctx extends AnyContextSymbol, V>(cfg: ContextConfig<Ctx, V>, updater: (prev: V) => V): ContextConfigUpdater<Ctx, V>;
|
|
75
|
+
/**
|
|
76
|
+
* @internal
|
|
77
|
+
* @experimental
|
|
78
|
+
* @__NO_SIDE_EFFECTS__
|
|
79
|
+
*/
|
|
80
|
+
export declare function $withFullContext<Ctx extends AnyContextSymbol, T>(sym: Ctx, contextRecord: ContextRecord<Ctx>, f: () => T, editor?: LexicalEditor): T;
|
|
81
|
+
/**
|
|
82
|
+
* @internal
|
|
83
|
+
* @experimental
|
|
84
|
+
* @__NO_SIDE_EFFECTS__
|
|
85
|
+
*/
|
|
86
|
+
export declare function $withContext<Ctx extends AnyContextSymbol>(sym: Ctx, $defaults?: (editor: LexicalEditor) => undefined | ContextRecord<Ctx>): (cfg: readonly AnyContextConfigPairOrUpdater<Ctx>[], editor?: LexicalEditor) => (<T>(f: () => T) => T);
|
|
87
|
+
/**
|
|
88
|
+
* @experimental
|
|
89
|
+
* @internal
|
|
90
|
+
* @__NO_SIDE_EFFECTS__
|
|
91
|
+
*/
|
|
92
|
+
export declare function createContextState<Tag extends symbol, V>(tag: Tag, name: string, getDefaultValue: () => V, isEqual?: (a: V, b: V) => boolean): ContextConfig<Tag, V>;
|
|
93
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
import type { DOMRenderConfig, DOMRenderExtensionOutput } from './types';
|
|
9
|
+
/**
|
|
10
|
+
* @experimental
|
|
11
|
+
*
|
|
12
|
+
* An extension that allows overriding the render and export behavior for an
|
|
13
|
+
* editor. This is highly experimental and subject to change from one version
|
|
14
|
+
* to the next.
|
|
15
|
+
**/
|
|
16
|
+
export declare const DOMRenderExtension: import("lexical").LexicalExtension<DOMRenderConfig, "@lexical/html/DOM", DOMRenderExtensionOutput, void>;
|