Comparing version 0.3.7 to 0.3.8
@@ -8,3 +8,3 @@ /** | ||
*/ | ||
export type { CommandListenerPriority, EditorConfig, EditorThemeClasses, IntentionallyMarkedAsDirtyElement, Klass, LexicalCommand, LexicalEditor, NodeMutation, ReadOnlyListener, SerializedEditor, Spread, } from './LexicalEditor'; | ||
export type { CommandListenerPriority, CommandPayloadType, EditorConfig, EditorThemeClasses, IntentionallyMarkedAsDirtyElement, Klass, LexicalCommand, LexicalEditor, NodeMutation, ReadOnlyListener, SerializedEditor, Spread, } from './LexicalEditor'; | ||
export type { EditorState, SerializedEditorState } from './LexicalEditorState'; | ||
@@ -11,0 +11,0 @@ export type { DOMChildConversion, DOMConversion, DOMConversionFn, DOMConversionMap, DOMConversionOutput, DOMExportOutput, LexicalNode, NodeKey, NodeMap, SerializedLexicalNode, } from './LexicalNode'; |
@@ -15,4 +15,4 @@ /** | ||
export declare const INSERT_PARAGRAPH_COMMAND: LexicalCommand<void>; | ||
export declare const CONTROLLED_TEXT_INSERTION_COMMAND: LexicalCommand<string>; | ||
export declare const PASTE_COMMAND: LexicalCommand<ClipboardEvent>; | ||
export declare const CONTROLLED_TEXT_INSERTION_COMMAND: LexicalCommand<InputEvent | string>; | ||
export declare const PASTE_COMMAND: LexicalCommand<ClipboardEvent | InputEvent>; | ||
export declare const REMOVE_TEXT_COMMAND: LexicalCommand<void>; | ||
@@ -43,4 +43,4 @@ export declare const DELETE_WORD_COMMAND: LexicalCommand<boolean>; | ||
export declare const DRAGEND_COMMAND: LexicalCommand<DragEvent>; | ||
export declare const COPY_COMMAND: LexicalCommand<ClipboardEvent>; | ||
export declare const CUT_COMMAND: LexicalCommand<ClipboardEvent>; | ||
export declare const COPY_COMMAND: LexicalCommand<ClipboardEvent | KeyboardEvent>; | ||
export declare const CUT_COMMAND: LexicalCommand<ClipboardEvent | KeyboardEvent>; | ||
export declare const CLEAR_EDITOR_COMMAND: LexicalCommand<void>; | ||
@@ -47,0 +47,0 @@ export declare const CLEAR_HISTORY_COMMAND: LexicalCommand<void>; |
@@ -26,2 +26,3 @@ /** | ||
export declare const IS_SUPERSCRIPT: number; | ||
export declare const IS_ALL_FORMATTING: number; | ||
export declare const IS_DIRECTIONLESS = 1; | ||
@@ -28,0 +29,0 @@ export declare const IS_UNMERGEABLE: number; |
@@ -118,3 +118,24 @@ /** | ||
export declare const COMMAND_PRIORITY_CRITICAL = 4; | ||
export declare type LexicalCommand<T = never> = Readonly<Record<string, unknown>>; | ||
export declare type LexicalCommand<TPayload> = Record<string, never>; | ||
/** | ||
* Type helper for extracting the payload type from a command. | ||
* | ||
* @example | ||
* ```ts | ||
* const MY_COMMAND = createCommand<SomeType>(); | ||
* | ||
* // ... | ||
* | ||
* editor.registerCommand(MY_COMMAND, payload => { | ||
* // Type of `payload` is inferred here. But lets say we want to extract a function to delegate to | ||
* handleMyCommand(editor, payload); | ||
* return true; | ||
* }); | ||
* | ||
* function handleMyCommand(editor: LexicalEditor, payload: CommandPayloadType<typeof MY_COMMAND>) { | ||
* // `payload` is of type `SomeType`, extracted from the command. | ||
* } | ||
* ``` | ||
*/ | ||
export declare type CommandPayloadType<TCommand extends LexicalCommand<unknown>> = TCommand extends LexicalCommand<infer TPayload> ? TPayload : never; | ||
declare type Commands = Map<LexicalCommand<unknown>, Array<Set<CommandListener<unknown>>>>; | ||
@@ -187,3 +208,3 @@ declare type Listeners = { | ||
hasNodes<T extends Klass<LexicalNode>>(nodes: Array<T>): boolean; | ||
dispatchCommand<P>(type: LexicalCommand<P>, payload: P): boolean; | ||
dispatchCommand<TCommand extends LexicalCommand<unknown>, TPayload extends CommandPayloadType<TCommand>>(type: TCommand, payload: TPayload): boolean; | ||
getDecorators<T>(): Record<NodeKey, T>; | ||
@@ -190,0 +211,0 @@ getRootElement(): null | HTMLElement; |
@@ -8,3 +8,3 @@ /** | ||
*/ | ||
import type { EditorThemeClasses, Klass, LexicalCommand, MutatedNodes, MutationListeners, NodeMutation, RegisteredNode, RegisteredNodes } from './LexicalEditor'; | ||
import type { CommandPayloadType, EditorThemeClasses, Klass, LexicalCommand, MutatedNodes, MutationListeners, NodeMutation, RegisteredNode, RegisteredNodes } from './LexicalEditor'; | ||
import type { EditorState } from './LexicalEditorState'; | ||
@@ -90,3 +90,3 @@ import type { LexicalNode, NodeKey } from './LexicalNode'; | ||
export declare function isFirefoxClipboardEvents(): boolean; | ||
export declare function dispatchCommand<P>(editor: LexicalEditor, type: LexicalCommand<P>, payload: P): boolean; | ||
export declare function dispatchCommand<TCommand extends LexicalCommand<unknown>, TPayload extends CommandPayloadType<TCommand>>(editor: LexicalEditor, type: TCommand, payload: TPayload): boolean; | ||
export declare function $textContentRequiresDoubleLinebreakAtEnd(node: ElementNode): boolean; | ||
@@ -93,0 +93,0 @@ export declare function getElementByKeyOrThrow(editor: LexicalEditor, key: NodeKey): HTMLElement; |
@@ -8,2 +8,2 @@ /** | ||
*/ | ||
export declare const VERSION = "0.3.7"; | ||
export declare const VERSION = "0.3.8"; |
@@ -12,3 +12,3 @@ { | ||
"license": "MIT", | ||
"version": "0.3.7", | ||
"version": "0.3.8", | ||
"main": "Lexical.js", | ||
@@ -15,0 +15,0 @@ "repository": { |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
437602
8764