) => void;
export type CommandListener = (payload: P, editor: LexicalEditor) => boolean;
export type ReadOnlyListener = (readOnly: boolean) => void;
-export type CommandListenerEditorPriority = 0;
-export type CommandListenerLowPriority = 1;
-export type CommandListenerNormalPriority = 2;
-export type CommandListenerHighPriority = 3;
-export type CommandListenerCriticalPriority = 4;
-
-export type CommandListenerPriority =
- | CommandListenerEditorPriority
- | CommandListenerLowPriority
- | CommandListenerNormalPriority
- | CommandListenerHighPriority
- | CommandListenerCriticalPriority;
+export type CommandListenerPriority = 0 | 1 | 2 | 3 | 4;
+export const COMMAND_PRIORITY_EDITOR = 0;
+export const COMMAND_PRIORITY_LOW = 1;
+export const COMMAND_PRIORITY_NORMAL = 2;
+export const COMMAND_PRIORITY_HIGH = 3;
+export const COMMAND_PRIORITY_CRITICAL = 4;
// eslint-disable-next-line no-unused-vars
export type LexicalCommand = $ReadOnly<{}>;
diff --git a/packages/lexical/src/__tests__/unit/LexicalEditor.test.js b/packages/lexical/src/__tests__/unit/LexicalEditor.test.js
index fc5e1f57c02..8e69efcd151 100644
--- a/packages/lexical/src/__tests__/unit/LexicalEditor.test.js
+++ b/packages/lexical/src/__tests__/unit/LexicalEditor.test.js
@@ -6,8 +6,6 @@
*
*/
-import type {LexicalEditor} from 'lexical';
-
import DEPRECATED__useLexicalRichText from '@lexical/react/DEPRECATED_useLexicalRichText';
import {
$createTableCellNode,
@@ -28,7 +26,9 @@ import {
$isTextNode,
$setCompositionKey,
$setSelection,
+ COMMAND_PRIORITY_EDITOR,
ElementNode,
+ LexicalEditor,
ParagraphNode,
TextNode,
} from 'lexical';
@@ -1485,7 +1485,7 @@ describe('LexicalEditor tests', () => {
const removeCommandListener = editor.registerCommand(
command,
commandListener,
- 0,
+ COMMAND_PRIORITY_EDITOR,
);
editor.dispatchCommand(command, payload);
editor.dispatchCommand(command, payload);
@@ -1508,12 +1508,12 @@ describe('LexicalEditor tests', () => {
const removeCommandListener = editor.registerCommand(
command,
commandListener,
- 0,
+ COMMAND_PRIORITY_EDITOR,
);
const removeCommandListenerTwo = editor.registerCommand(
command,
commandListenerTwo,
- 0,
+ COMMAND_PRIORITY_EDITOR,
);
expect(editor._commands).toEqual(
new Map([
diff --git a/packages/lexical/src/index.js b/packages/lexical/src/index.js
index 5155479c389..c4daf78b85b 100644
--- a/packages/lexical/src/index.js
+++ b/packages/lexical/src/index.js
@@ -7,7 +7,14 @@
* @flow strict
*/
-import {createEditor} from './LexicalEditor';
+import {
+ COMMAND_PRIORITY_CRITICAL,
+ COMMAND_PRIORITY_EDITOR,
+ COMMAND_PRIORITY_HIGH,
+ COMMAND_PRIORITY_LOW,
+ COMMAND_PRIORITY_NORMAL,
+ createEditor,
+} from './LexicalEditor';
import {$createNodeFromParse} from './LexicalParsing';
import {
$createEmptyGridSelection as $createGridSelection,
@@ -77,6 +84,11 @@ export {
$nodesOfType,
$setCompositionKey,
$setSelection,
+ COMMAND_PRIORITY_CRITICAL,
+ COMMAND_PRIORITY_EDITOR,
+ COMMAND_PRIORITY_HIGH,
+ COMMAND_PRIORITY_LOW,
+ COMMAND_PRIORITY_NORMAL,
createEditor,
DecoratorNode,
ElementNode,