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;
|
maxWidth: number;
|
||||||
width?: number;
|
width?: number;
|
||||||
fileKey?: string;
|
fileKey?: string;
|
||||||
uploadProgress?: number;
|
// uploadProgress and uploadError are runtime-only, not serialized
|
||||||
uploadError?: string;
|
|
||||||
},
|
},
|
||||||
SerializedLexicalNode
|
SerializedLexicalNode
|
||||||
>;
|
>;
|
||||||
@@ -84,7 +83,7 @@ export class ImageNode extends DecoratorNode<JSX.Element> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static importJSON(serializedNode: SerializedImageNode): ImageNode {
|
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
|
// Generate src from fileKey if available, otherwise use empty string
|
||||||
const src = fileKey ? '' : ''; // src will be generated from fileKey when rendering
|
const src = fileKey ? '' : ''; // src will be generated from fileKey when rendering
|
||||||
@@ -96,8 +95,7 @@ export class ImageNode extends DecoratorNode<JSX.Element> {
|
|||||||
src,
|
src,
|
||||||
width,
|
width,
|
||||||
fileKey,
|
fileKey,
|
||||||
uploadProgress,
|
// uploadProgress and uploadError are not imported - they're runtime-only
|
||||||
uploadError,
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -158,8 +156,7 @@ export class ImageNode extends DecoratorNode<JSX.Element> {
|
|||||||
version: 1,
|
version: 1,
|
||||||
width: this.__width === 'inherit' ? 0 : this.__width,
|
width: this.__width === 'inherit' ? 0 : this.__width,
|
||||||
fileKey: this.__fileKey,
|
fileKey: this.__fileKey,
|
||||||
uploadProgress: this.__uploadProgress,
|
// Don't export uploadProgress or uploadError - they're runtime-only UI state
|
||||||
uploadError: this.__uploadError,
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user