Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[lexical] Bug Fix: Flow is missing some variables and functions #6977

Merged
merged 2 commits into from
Dec 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions packages/lexical/flow/Lexical.js.flow
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ export type EditorThemeClasses = {
ulDepth?: Array<EditorThemeClassName>,
ol?: EditorThemeClassName,
olDepth?: Array<EditorThemeClassName>,
checklist?: EditorThemeClassName,
listitem?: EditorThemeClassName,
listitemChecked?: EditorThemeClassName,
listitemUnchecked?: EditorThemeClassName,
Expand Down Expand Up @@ -361,7 +362,7 @@ export type DOMConversion = {
conversion: DOMConversionFn,
priority: 0 | 1 | 2 | 3 | 4,
};
export type DOMConversionFn = (element: Node) => DOMConversionOutput;
export type DOMConversionFn = (element: Node) => DOMConversionOutput | null;
export type DOMChildConversion = (
lexicalNode: LexicalNode,
parentLexicalNode: ?LexicalNode | null,
Expand Down Expand Up @@ -451,13 +452,16 @@ declare export function $isBlockElementNode(
): node is ElementNode;

export interface BaseSelection {
clone(): BaseSelection;
dirty: boolean;
clone(): BaseSelection;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

curious about the use cases outside of meta for these added api

just a nit, rearranging clone to be after dirty would break the unenforced abc sorting for props

other then that lgtm

extract(): Array<LexicalNode>;
getNodes(): Array<LexicalNode>;
getStartEndPoints(): null | [PointType, PointType];
getTextContent(): string;
insertRawText(text: string): void;
is(selection: null | BaseSelection): boolean;
isBackward(): boolean;
isCollapsed(): boolean;
insertText(text: string): void;
insertNodes(nodes: Array<LexicalNode>): void;
getCachedNodes(): null | Array<LexicalNode>;
Expand All @@ -469,6 +473,8 @@ declare export class NodeSelection implements BaseSelection {
dirty: boolean;
constructor(objects: Set<NodeKey>): void;
is(selection: null | BaseSelection): boolean;
isBackward(): boolean;
isCollapsed(): boolean;
Comment on lines +476 to +477
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it useful to add this here, when it already declares that BaseSelection is implemented?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I remove those 2 declarations, npm run ci-check return this error

Cannot implement BaseSelection [1] with NodeSelection because property isCollapsed is missing in NodeSelection [2] but exists in BaseSelection [1]. [prop-missing]

add(key: NodeKey): void;
delete(key: NodeKey): void;
clear(): void;
Expand All @@ -478,6 +484,7 @@ declare export class NodeSelection implements BaseSelection {
insertRawText(): void;
insertText(): void;
getNodes(): Array<LexicalNode>;
getStartEndPoints(): null;
getTextContent(): string;
insertNodes(nodes: Array<LexicalNode>): void;
getCachedNodes(): null | Array<LexicalNode>;
Expand All @@ -493,6 +500,7 @@ declare export class RangeSelection implements BaseSelection {
focus: PointType;
dirty: boolean;
format: number;
style: string;
constructor(anchor: PointType, focus: PointType, format: number): void;
is(selection: null | BaseSelection): boolean;
isBackward(): boolean;
Expand Down Expand Up @@ -530,6 +538,8 @@ declare export class RangeSelection implements BaseSelection {
insertNodes(nodes: Array<LexicalNode>): void;
getCachedNodes(): null | Array<LexicalNode>;
setCachedNodes(nodes: null | Array<LexicalNode>): void;
forwardDeletion(anchor: PointType, anchorNode: ElementNode | TextNode, isBackward: boolean): boolean;
getStartEndPoints(): null | [PointType, PointType];
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This also looks to be the same as BaseSelection

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as the other comment, if I remove those 2 declarations, npm run ci-check return this error

Cannot implement BaseSelection [1] with RangeSelection because property getStartEndPoints is missing in
RangeSelection [2] but exists in BaseSelection [1]. [prop-missing]

}
export type TextPoint = TextPointType;
type TextPointType = {
Expand Down
Loading