mirror of
https://github.com/rzmk/learnhouse.git
synced 2025-12-19 04:19:25 +00:00
fix: Embed block inputs accepts empty input #364
This commit is contained in:
parent
780968ba06
commit
a6506d5339
1 changed files with 19 additions and 12 deletions
|
|
@ -53,22 +53,29 @@ function EmbedObjectsComponent(props: any) {
|
|||
|
||||
const handleUrlChange = (event: React.ChangeEvent<HTMLInputElement>) => {
|
||||
const newUrl = event.target.value;
|
||||
// Sanitize the URL
|
||||
const sanitizedUrl = DOMPurify.sanitize(newUrl);
|
||||
setEmbedUrl(sanitizedUrl);
|
||||
props.updateAttributes({
|
||||
embedUrl: sanitizedUrl,
|
||||
embedType: 'url',
|
||||
});
|
||||
const trimmedUrl = newUrl.trim();
|
||||
// Only update if URL is not just whitespace
|
||||
if (newUrl === '' || trimmedUrl) {
|
||||
const sanitizedUrl = DOMPurify.sanitize(newUrl);
|
||||
setEmbedUrl(sanitizedUrl);
|
||||
props.updateAttributes({
|
||||
embedUrl: sanitizedUrl,
|
||||
embedType: 'url',
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
const handleCodeChange = (event: React.ChangeEvent<HTMLTextAreaElement>) => {
|
||||
const newCode = event.target.value;
|
||||
setEmbedCode(newCode);
|
||||
props.updateAttributes({
|
||||
embedCode: newCode,
|
||||
embedType: 'code',
|
||||
});
|
||||
const trimmedCode = newCode.trim();
|
||||
// Only update if code is not just whitespace
|
||||
if (newCode === '' || trimmedCode) {
|
||||
setEmbedCode(newCode);
|
||||
props.updateAttributes({
|
||||
embedCode: newCode,
|
||||
embedType: 'code',
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
const handleResizeStart = (event: React.MouseEvent<HTMLDivElement>, direction: 'horizontal' | 'vertical') => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue