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 handleUrlChange = (event: React.ChangeEvent<HTMLInputElement>) => {
|
||||||
const newUrl = event.target.value;
|
const newUrl = event.target.value;
|
||||||
// Sanitize the URL
|
const trimmedUrl = newUrl.trim();
|
||||||
const sanitizedUrl = DOMPurify.sanitize(newUrl);
|
// Only update if URL is not just whitespace
|
||||||
setEmbedUrl(sanitizedUrl);
|
if (newUrl === '' || trimmedUrl) {
|
||||||
props.updateAttributes({
|
const sanitizedUrl = DOMPurify.sanitize(newUrl);
|
||||||
embedUrl: sanitizedUrl,
|
setEmbedUrl(sanitizedUrl);
|
||||||
embedType: 'url',
|
props.updateAttributes({
|
||||||
});
|
embedUrl: sanitizedUrl,
|
||||||
|
embedType: 'url',
|
||||||
|
});
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleCodeChange = (event: React.ChangeEvent<HTMLTextAreaElement>) => {
|
const handleCodeChange = (event: React.ChangeEvent<HTMLTextAreaElement>) => {
|
||||||
const newCode = event.target.value;
|
const newCode = event.target.value;
|
||||||
setEmbedCode(newCode);
|
const trimmedCode = newCode.trim();
|
||||||
props.updateAttributes({
|
// Only update if code is not just whitespace
|
||||||
embedCode: newCode,
|
if (newCode === '' || trimmedCode) {
|
||||||
embedType: 'code',
|
setEmbedCode(newCode);
|
||||||
});
|
props.updateAttributes({
|
||||||
|
embedCode: newCode,
|
||||||
|
embedType: 'code',
|
||||||
|
});
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleResizeStart = (event: React.MouseEvent<HTMLDivElement>, direction: 'horizontal' | 'vertical') => {
|
const handleResizeStart = (event: React.MouseEvent<HTMLDivElement>, direction: 'horizontal' | 'vertical') => {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue