-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLinkDialog.tsx
More file actions
65 lines (61 loc) · 1.73 KB
/
Copy pathLinkDialog.tsx
File metadata and controls
65 lines (61 loc) · 1.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import { memo, useCallback } from 'react';
import Button from 'devextreme-react/button';
import HtmlEditor, { Item, Toolbar } from 'devextreme-react/html-editor';
import Popup from 'devextreme-react/popup';
import TextBox, { type TextBoxTypes } from 'devextreme-react/text-box';
import type { LinkDialogProps } from './types';
const linkApplyButtonAttrs = { class: 'link-apply-button' };
function LinkDialog({
isVisible,
url,
onApply,
onHide,
onLinkEditorInitialized,
onUrlChange,
}: LinkDialogProps): JSX.Element {
const handleUrlChange = useCallback(
(event: TextBoxTypes.ValueChangedEvent) => onUrlChange(event.value ?? ''),
[onUrlChange],
);
return (
<Popup
showTitle
title="Insert Formatted Link"
width={450}
height={380}
deferRendering={false}
visible={isVisible}
showCloseButton
onHiding={onHide}
>
<div className="popup-content">
<TextBox
placeholder="Enter URL (e.g., https://google.com)..."
showClearButton
label="URL:"
labelMode="outside"
value={url}
onValueChanged={handleUrlChange}
/>
<div className="link-text-title">Link Text:</div>
<HtmlEditor height={120} onInitialized={onLinkEditorInitialized}>
<Toolbar>
<Item name="bold" />
<Item name="italic" />
<Item name="underline" />
<Item name="strike" />
<Item name="color" />
</Toolbar>
</HtmlEditor>
<Button
elementAttr={linkApplyButtonAttrs}
text="Insert"
type="default"
width="100%"
onClick={onApply}
/>
</div>
</Popup>
);
}
export default memo(LinkDialog);