@web-atoms/web-controls 2.1.12 → 2.1.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/basic/FormField.d.ts +8 -0
- package/dist/basic/FormField.d.ts.map +1 -0
- package/dist/basic/FormField.js +39 -0
- package/dist/basic/FormField.js.map +1 -0
- package/dist/basic/PopupButton.d.ts.map +1 -1
- package/dist/basic/PopupButton.js +1 -2
- package/dist/basic/PopupButton.js.map +1 -1
- package/dist/form/AtomField.d.ts +4 -17
- package/dist/form/AtomField.d.ts.map +1 -1
- package/dist/form/AtomField.js +22 -63
- package/dist/form/AtomField.js.map +1 -1
- package/dist/html-editor/HtmlEditor.d.ts +2 -0
- package/dist/html-editor/HtmlEditor.d.ts.map +1 -1
- package/dist/html-editor/HtmlEditor.js +36 -4
- package/dist/html-editor/HtmlEditor.js.map +1 -1
- package/dist/html-editor/commands/AddImage.d.ts +4 -1
- package/dist/html-editor/commands/AddImage.d.ts.map +1 -1
- package/dist/html-editor/commands/AddImage.js +46 -2
- package/dist/html-editor/commands/AddImage.js.map +1 -1
- package/dist/html-editor/commands/AddLink.d.ts.map +1 -1
- package/dist/html-editor/commands/AddLink.js +14 -8
- package/dist/html-editor/commands/AddLink.js.map +1 -1
- package/dist/html-editor/commands/CommandButton.d.ts.map +1 -1
- package/dist/html-editor/commands/CommandButton.js +3 -1
- package/dist/html-editor/commands/CommandButton.js.map +1 -1
- package/dist/html-editor/commands/Source.d.ts +4 -0
- package/dist/html-editor/commands/Source.d.ts.map +1 -0
- package/dist/html-editor/commands/Source.js +71 -0
- package/dist/html-editor/commands/Source.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/src/basic/FormField.tsx +47 -0
- package/src/basic/PopupButton.tsx +1 -2
- package/src/form/AtomField.tsx +18 -68
- package/src/html-editor/HtmlEditor.tsx +36 -2
- package/src/html-editor/commands/AddImage.tsx +45 -1
- package/src/html-editor/commands/AddLink.tsx +20 -13
- package/src/html-editor/commands/CommandButton.tsx +3 -1
- package/src/html-editor/commands/Source.tsx +52 -0
|
@@ -6,6 +6,7 @@ import StyleRule from "@web-atoms/core/dist/style/StyleRule";
|
|
|
6
6
|
import { AtomToggleButtonBar } from "@web-atoms/core/dist/web/controls/AtomToggleButtonBar";
|
|
7
7
|
import PopupService, { PopupWindow } from "@web-atoms/core/dist/web/services/PopupService";
|
|
8
8
|
import CSS from "@web-atoms/core/dist/web/styles/CSS";
|
|
9
|
+
import FormField from "../../basic/FormField";
|
|
9
10
|
import type { HtmlEditorControl } from "../HtmlEditor";
|
|
10
11
|
import CommandButton, { notSet } from "./CommandButton";
|
|
11
12
|
|
|
@@ -46,28 +47,34 @@ class LinkDialog extends PopupWindow {
|
|
|
46
47
|
this.type = "web-page";
|
|
47
48
|
this.title = "Create Link";
|
|
48
49
|
this.render(<div class={linkDialogCss}>
|
|
49
|
-
<
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
50
|
+
<FormField label="Type">
|
|
51
|
+
<AtomToggleButtonBar
|
|
52
|
+
items={linkTypes}
|
|
53
|
+
value={Bind.twoWays(() => this.type)}/>
|
|
54
|
+
</FormField>
|
|
55
|
+
<FormField label="Link" required={true}>
|
|
56
|
+
<input
|
|
57
|
+
placeholder="https://..."
|
|
58
|
+
value={Bind.twoWaysImmediate(() => this.link)}/>
|
|
59
|
+
</FormField>
|
|
55
60
|
<div class="command-bar">
|
|
56
61
|
<button
|
|
57
62
|
text="Add"
|
|
58
|
-
eventClick={Bind.event((
|
|
59
|
-
setTimeout(() => {
|
|
60
|
-
this.viewModel.close(this.link);
|
|
61
|
-
}, 1)
|
|
62
|
-
)} />
|
|
63
|
+
eventClick={Bind.event(() => this.viewModel.close(this.toLink(this.link)))} />
|
|
63
64
|
</div>
|
|
64
65
|
</div>);
|
|
65
66
|
}
|
|
67
|
+
|
|
68
|
+
private toLink(link: string): string {
|
|
69
|
+
switch (this.type) {
|
|
70
|
+
case "web-page":
|
|
71
|
+
return /^(http|https)\:\/\//.test(link) ? link : "";
|
|
72
|
+
}
|
|
73
|
+
}
|
|
66
74
|
}
|
|
67
75
|
|
|
68
76
|
function showDialog(s: HtmlEditorControl, e: Event): Promise<string> {
|
|
69
|
-
|
|
70
|
-
return popupService.showWindow(s.element, LinkDialog);
|
|
77
|
+
return PopupService.showWindow(s.element, LinkDialog);
|
|
71
78
|
}
|
|
72
79
|
|
|
73
80
|
export default function AddLink({
|
|
@@ -35,7 +35,9 @@ function insert(callback: (s: HtmlEditorControl, e: Event) => Promise<string> |
|
|
|
35
35
|
r = await r;
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
|
-
|
|
38
|
+
if (r) {
|
|
39
|
+
s.executeCommand(command ?? "insertHTML", false, r as string);
|
|
40
|
+
}
|
|
39
41
|
};
|
|
40
42
|
}
|
|
41
43
|
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import Bind from "@web-atoms/core/dist/core/Bind";
|
|
2
|
+
import { BindableProperty } from "@web-atoms/core/dist/core/BindableProperty";
|
|
3
|
+
import XNode from "@web-atoms/core/dist/core/XNode";
|
|
4
|
+
import StyleRule from "@web-atoms/core/dist/style/StyleRule";
|
|
5
|
+
import PopupService, { PopupWindow } from "@web-atoms/core/dist/web/services/PopupService";
|
|
6
|
+
import CSS from "@web-atoms/core/dist/web/styles/CSS";
|
|
7
|
+
import { HtmlEditorControl } from "../HtmlEditor";
|
|
8
|
+
import CommandButton from "./CommandButton";
|
|
9
|
+
|
|
10
|
+
const css = CSS(StyleRule()
|
|
11
|
+
.child(StyleRule("textarea")
|
|
12
|
+
.minHeight(500)
|
|
13
|
+
.minWidth(700)
|
|
14
|
+
)
|
|
15
|
+
);
|
|
16
|
+
|
|
17
|
+
async function showDialog(s: HtmlEditorControl, e: Event): Promise<string> {
|
|
18
|
+
|
|
19
|
+
class SourceDialog extends PopupWindow {
|
|
20
|
+
|
|
21
|
+
@BindableProperty
|
|
22
|
+
public source: string;
|
|
23
|
+
|
|
24
|
+
protected create(): void {
|
|
25
|
+
this.source = s.htmlContent;
|
|
26
|
+
this.render(<div class={css}>
|
|
27
|
+
<textarea value={Bind.twoWaysImmediate(() => this.source)}/>
|
|
28
|
+
<div class="command-bar">
|
|
29
|
+
<button
|
|
30
|
+
eventClick={Bind.event(() => this.viewModel.close(this.source))}
|
|
31
|
+
text="Save"/>
|
|
32
|
+
</div>
|
|
33
|
+
</div>);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const result = await PopupService.showWindow(s.element, SourceDialog);
|
|
39
|
+
s.htmlContent = result as string;
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export default function Source({
|
|
44
|
+
insertCommand = "createLink"
|
|
45
|
+
}) {
|
|
46
|
+
return CommandButton({
|
|
47
|
+
icon: "ri-edit-box-fill",
|
|
48
|
+
insertCommand,
|
|
49
|
+
eventInsertHtml: showDialog,
|
|
50
|
+
title: "Create Hyper Link"
|
|
51
|
+
});
|
|
52
|
+
}
|