Comparing version 0.1.16 to 0.1.17
@@ -12,2 +12,51 @@ /** | ||
/** | ||
* LexicalCommands | ||
*/ | ||
export type LexicalCommand<P> = $ReadOnly<{}>; | ||
export var SELECTION_CHANGE_COMMAND: LexicalCommand<void>; | ||
export var CLICK_COMMAND: LexicalCommand<MouseEvent>; | ||
export var DELETE_CHARACTER_COMMAND: LexicalCommand<boolean>; | ||
export var INSERT_LINE_BREAK_COMMAND: LexicalCommand<boolean>; | ||
export var INSERT_PARAGRAPH_COMMAND: LexicalCommand<void>; | ||
export var INSERT_TEXT_COMMAND: LexicalCommand<InputEvent | string>; | ||
export var PASTE_COMMAND: LexicalCommand<ClipboardEvent>; | ||
export var REMOVE_TEXT_COMMAND: LexicalCommand<void>; | ||
export var DELETE_WORD_COMMAND: LexicalCommand<boolean>; | ||
export var DELETE_LINE_COMMAND: LexicalCommand<boolean>; | ||
export var FORMAT_TEXT_COMMAND: LexicalCommand<TextFormatType>; | ||
export var UNDO_COMMAND: LexicalCommand<void>; | ||
export var REDO_COMMAND: LexicalCommand<void>; | ||
export var KEY_ARROW_RIGHT_COMMAND: LexicalCommand<KeyboardEvent>; | ||
export var KEY_ARROW_LEFT_COMMAND: LexicalCommand<KeyboardEvent>; | ||
export var KEY_ARROW_UP_COMMAND: LexicalCommand<KeyboardEvent>; | ||
export var KEY_ARROW_DOWN_COMMAND: LexicalCommand<KeyboardEvent>; | ||
export var KEY_ENTER_COMMAND: LexicalCommand<KeyboardEvent>; | ||
export var KEY_BACKSPACE_COMMAND: LexicalCommand<KeyboardEvent>; | ||
export var KEY_ESCAPE_COMMAND: LexicalCommand<KeyboardEvent>; | ||
export var KEY_DELETE_COMMAND: LexicalCommand<KeyboardEvent>; | ||
export var KEY_TAB_COMMAND: LexicalCommand<KeyboardEvent>; | ||
export var INDENT_CONTENT_COMMAND: LexicalCommand<void>; | ||
export var OUTDENT_CONTENT_COMMAND: LexicalCommand<void>; | ||
export var DROP_COMMAND: LexicalCommand<DragEvent>; | ||
export var FORMAT_ELEMENT_COMMAND: LexicalCommand<ElementFormatType>; | ||
export var DRAGSTART_COMMAND: LexicalCommand<DragEvent>; | ||
export var COPY_COMMAND: LexicalCommand<ClipboardEvent>; | ||
export var CUT_COMMAND: LexicalCommand<ClipboardEvent>; | ||
export var CLEAR_EDITOR_COMMAND: LexicalCommand<void>; | ||
export var CLEAR_HISTORY_COMMAND: LexicalCommand<void>; | ||
export var CAN_REDO_COMMAND: LexicalCommand<boolean>; | ||
export var CAN_UNDO_COMMAND: LexicalCommand<boolean>; | ||
export var FOCUS_COMMAND: LexicalCommand<FocusEvent>; | ||
export var BLUR_COMMAND: LexicalCommand<FocusEvent>; | ||
export var INSERT_TABLE_COMMAND: LexicalCommand<{ | ||
rows: string; | ||
columns: string; | ||
}>; | ||
export var READ_ONLY_COMMAND: LexicalCommand<void>; | ||
export declare function createCommand<T>(): LexicalCommand<T>; | ||
/** | ||
* LexicalEditor | ||
@@ -33,10 +82,7 @@ */ | ||
type MutationListener = (nodes: Map<NodeKey, NodeMutation>) => void; | ||
type CommandListener = ( | ||
type: string, | ||
payload: CommandPayload, | ||
editor: LexicalEditor, | ||
) => boolean; | ||
type CommandListener<P> = (payload: P, editor: LexicalEditor) => boolean; | ||
export type ReadOnlyListener = (readOnly: boolean) => void; | ||
type CommandPayload = any; | ||
type InternalCommandListener = CommandListener<any>; | ||
type Listeners = { | ||
@@ -48,3 +94,3 @@ decorator: Set<DecoratorListener>; | ||
update: Set<UpdateListener>; | ||
command: Array<Set<CommandListener>>; | ||
command: Map<string, Array<Set<InternalCommandListener>>>; | ||
}; | ||
@@ -88,22 +134,21 @@ type RegisteredNodes = Map<string, RegisteredNode>; | ||
isComposing(): boolean; | ||
addListener(type: 'update', listener: UpdateListener): () => void; | ||
addListener(type: 'root', listener: RootListener): () => void; | ||
addListener(type: 'decorator', listener: DecoratorListener): () => void; | ||
addListener(type: 'textcontent', listener: TextContentListener): () => void; | ||
addListener( | ||
type: 'command', | ||
listener: CommandListener, | ||
registerUpdateListener(listener: UpdateListener): () => void; | ||
registerRootListener(listener: RootListener): () => void; | ||
registerDecoratorListener(listener: DecoratorListener): () => void; | ||
registerTextContentListener(listener: TextContentListener): () => void; | ||
registerCommand<P>( | ||
command: LexicalCommand<P>, | ||
listener: CommandListener<P>, | ||
priority: CommandListenerPriority, | ||
): () => void; | ||
addListener(type: 'readonly', listener: ReadOnlyListener): () => void; | ||
addListener( | ||
type: 'mutation', | ||
registerReadOnlyListener(listener: ReadOnlyListener): () => void; | ||
registerMutationListener( | ||
klass: Class<LexicalNode>, | ||
listener: MutationListener, | ||
): () => void; | ||
addNodeTransform<T extends LexicalNode>( | ||
registerNodeTransform<T extends LexicalNode>( | ||
klass: Class<T>, | ||
listener: Transform<T>, | ||
): () => void; | ||
execCommand(type: string, payload: CommandPayload): boolean; | ||
dispatchCommand(type: string, payload: P): boolean; | ||
hasNodes(nodes: Array<Class<LexicalNode>>): boolean; | ||
@@ -231,3 +276,3 @@ getDecorators<X>(): Record<NodeKey, X>; | ||
}; | ||
export declare class EditorState { | ||
export interface EditorState { | ||
_nodeMap: NodeMap; | ||
@@ -260,3 +305,6 @@ _selection: null | RangeSelection | NodeSelection | GridSelection; | ||
) => DOMConversionOutput; | ||
export type DOMChildConversion = (lexicalNode: LexicalNode) => void; | ||
export type DOMChildConversion = ( | ||
lexicalNode: LexicalNode, | ||
parentLexicalNode: ?(LexicalNode | null), | ||
) => ?(LexicalNode | void | null); | ||
export type DOMConversionMap = Record< | ||
@@ -263,0 +311,0 @@ NodeName, |
{ | ||
"name": "lexical", | ||
"author": { | ||
"name": "Dominic Gannaway", | ||
"email": "dg@domgan.com" | ||
}, | ||
"description": "Lexical is an extensible text editor library that provides excellent reliability, accessible and performance.", | ||
@@ -16,3 +12,3 @@ "keywords": [ | ||
"license": "MIT", | ||
"version": "0.1.16", | ||
"version": "0.1.17", | ||
"main": "Lexical.js", | ||
@@ -19,0 +15,0 @@ "typings": "Lexical.d.ts", |
# `lexical` | ||
Lexical is an extensible JavaScript text-editor that provides reliable, accessible and performant typing experiences for the web. | ||
Lexical is an extensible JavaScript web text-editor framework with an emphasis on reliability, accessibility and performance. Lexical aims to provide a best-in-class developer experience, so you can easily prototype and build features with confidence. Combined with a highly extensible architecture, Lexical allows developers to create unique text editing experiences that scale in size and functionality. | ||
@@ -92,4 +92,4 @@ The core of Lexical is a dependency-free text editor engine that allows for powerful, simple and complex, | ||
- Setting the editor state via `editor.setEditorState()` | ||
- Applying a change as part of an existing update via `editor.addNodeTransform()` | ||
- Using a command listener with `editor.addListener('command', () => {...}, priority)` | ||
- Applying a change as part of an existing update via `editor.registerNodeTransform()` | ||
- Using a command listener with `editor.registerCommand( () => {...}, priority)` | ||
@@ -144,3 +144,3 @@ The most common way to update the editor is to use `editor.update()`. Calling this function | ||
```js | ||
editor.addListener('update', ({editorState}) => { | ||
editor.registerUpdateListener(({editorState}) => { | ||
// The latest EditorState can be found as `editorState`. | ||
@@ -147,0 +147,0 @@ // To read the contents of the EditorState, use the following API: |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
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
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
No contributors or author data
MaintenancePackage does not specify a list of contributors or an author in package.json.
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
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 4 instances in 1 package
3
1
387203
8
8116
2