refactor: clean up ImageNode code structure and improve readability
All checks were successful
CI - Build and Push / Build and Push Docker Image (push) Successful in 17s
All checks were successful
CI - Build and Push / Build and Push Docker Image (push) Successful in 17s
This commit is contained in:
@@ -49,8 +49,7 @@ export type SerializedImageNode = Spread<
|
||||
maxWidth: number;
|
||||
width?: number;
|
||||
fileKey?: string;
|
||||
uploadProgress?: number;
|
||||
uploadError?: string;
|
||||
// uploadProgress and uploadError are runtime-only, not serialized
|
||||
},
|
||||
SerializedLexicalNode
|
||||
>;
|
||||
@@ -84,7 +83,7 @@ export class ImageNode extends DecoratorNode<JSX.Element> {
|
||||
}
|
||||
|
||||
static importJSON(serializedNode: SerializedImageNode): ImageNode {
|
||||
const { altText, height, width, maxWidth, fileKey, uploadProgress, uploadError } = serializedNode;
|
||||
const { altText, height, width, maxWidth, fileKey } = serializedNode;
|
||||
|
||||
// Generate src from fileKey if available, otherwise use empty string
|
||||
const src = fileKey ? '' : ''; // src will be generated from fileKey when rendering
|
||||
@@ -96,8 +95,7 @@ export class ImageNode extends DecoratorNode<JSX.Element> {
|
||||
src,
|
||||
width,
|
||||
fileKey,
|
||||
uploadProgress,
|
||||
uploadError,
|
||||
// uploadProgress and uploadError are not imported - they're runtime-only
|
||||
});
|
||||
}
|
||||
|
||||
@@ -158,8 +156,7 @@ export class ImageNode extends DecoratorNode<JSX.Element> {
|
||||
version: 1,
|
||||
width: this.__width === 'inherit' ? 0 : this.__width,
|
||||
fileKey: this.__fileKey,
|
||||
uploadProgress: this.__uploadProgress,
|
||||
uploadError: this.__uploadError,
|
||||
// Don't export uploadProgress or uploadError - they're runtime-only UI state
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user