@web-atoms/web-controls 2.1.8 → 2.1.12
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/PopupButton.d.ts +3 -1
- package/dist/basic/PopupButton.d.ts.map +1 -1
- package/dist/basic/PopupButton.js +13 -4
- package/dist/basic/PopupButton.js.map +1 -1
- package/dist/html-editor/HtmlEditor.d.ts +23 -0
- package/dist/html-editor/HtmlEditor.d.ts.map +1 -0
- package/dist/html-editor/HtmlEditor.js +208 -0
- package/dist/html-editor/HtmlEditor.js.map +1 -0
- package/dist/html-editor/commands/AddImage.d.ts +5 -0
- package/dist/html-editor/commands/AddImage.d.ts.map +1 -0
- package/dist/html-editor/commands/AddImage.js +23 -0
- package/dist/html-editor/commands/AddImage.js.map +1 -0
- package/dist/html-editor/commands/AddLink.d.ts +4 -0
- package/dist/html-editor/commands/AddLink.d.ts.map +1 -0
- package/dist/html-editor/commands/AddLink.js +86 -0
- package/dist/html-editor/commands/AddLink.js.map +1 -0
- package/dist/html-editor/commands/Align.d.ts +2 -0
- package/dist/html-editor/commands/Align.d.ts.map +1 -0
- package/dist/html-editor/commands/Align.js +24 -0
- package/dist/html-editor/commands/Align.js.map +1 -0
- package/dist/html-editor/commands/Bold.d.ts +3 -0
- package/dist/html-editor/commands/Bold.d.ts.map +1 -0
- package/dist/html-editor/commands/Bold.js +20 -0
- package/dist/html-editor/commands/Bold.js.map +1 -0
- package/dist/html-editor/commands/ChangeColor.d.ts +2 -0
- package/dist/html-editor/commands/ChangeColor.d.ts.map +1 -0
- package/dist/html-editor/commands/ChangeColor.js +146 -0
- package/dist/html-editor/commands/ChangeColor.js.map +1 -0
- package/dist/html-editor/commands/ChangeFont.d.ts +6 -0
- package/dist/html-editor/commands/ChangeFont.d.ts.map +1 -0
- package/dist/html-editor/commands/ChangeFont.js +72 -0
- package/dist/html-editor/commands/ChangeFont.js.map +1 -0
- package/dist/html-editor/commands/ChangeFontSize.d.ts +3 -0
- package/dist/html-editor/commands/ChangeFontSize.d.ts.map +1 -0
- package/dist/html-editor/commands/ChangeFontSize.js +22 -0
- package/dist/html-editor/commands/ChangeFontSize.js.map +1 -0
- package/dist/html-editor/commands/Command.d.ts +12 -0
- package/dist/html-editor/commands/Command.d.ts.map +1 -0
- package/dist/html-editor/commands/Command.js +43 -0
- package/dist/html-editor/commands/Command.js.map +1 -0
- package/dist/html-editor/commands/CommandButton.d.ts +19 -0
- package/dist/html-editor/commands/CommandButton.d.ts.map +1 -0
- package/dist/html-editor/commands/CommandButton.js +53 -0
- package/dist/html-editor/commands/CommandButton.js.map +1 -0
- package/dist/html-editor/commands/Headings.d.ts +2 -0
- package/dist/html-editor/commands/Headings.d.ts.map +1 -0
- package/dist/html-editor/commands/Headings.js +26 -0
- package/dist/html-editor/commands/Headings.js.map +1 -0
- package/dist/html-editor/commands/HorizontalRule.d.ts +3 -0
- package/dist/html-editor/commands/HorizontalRule.d.ts.map +1 -0
- package/dist/html-editor/commands/HorizontalRule.js +20 -0
- package/dist/html-editor/commands/HorizontalRule.js.map +1 -0
- package/dist/html-editor/commands/IndentLess.d.ts +2 -0
- package/dist/html-editor/commands/IndentLess.d.ts.map +1 -0
- package/dist/html-editor/commands/IndentLess.js +20 -0
- package/dist/html-editor/commands/IndentLess.js.map +1 -0
- package/dist/html-editor/commands/IndentMore.d.ts +2 -0
- package/dist/html-editor/commands/IndentMore.d.ts.map +1 -0
- package/dist/html-editor/commands/IndentMore.js +20 -0
- package/dist/html-editor/commands/IndentMore.js.map +1 -0
- package/dist/html-editor/commands/Italic.d.ts +3 -0
- package/dist/html-editor/commands/Italic.d.ts.map +1 -0
- package/dist/html-editor/commands/Italic.js +20 -0
- package/dist/html-editor/commands/Italic.js.map +1 -0
- package/dist/html-editor/commands/NumberedList.d.ts +2 -0
- package/dist/html-editor/commands/NumberedList.d.ts.map +1 -0
- package/dist/html-editor/commands/NumberedList.js +20 -0
- package/dist/html-editor/commands/NumberedList.js.map +1 -0
- package/dist/html-editor/commands/Quote.d.ts +2 -0
- package/dist/html-editor/commands/Quote.d.ts.map +1 -0
- package/dist/html-editor/commands/Quote.js +20 -0
- package/dist/html-editor/commands/Quote.js.map +1 -0
- package/dist/html-editor/commands/RemoveFormat.d.ts +2 -0
- package/dist/html-editor/commands/RemoveFormat.d.ts.map +1 -0
- package/dist/html-editor/commands/RemoveFormat.js +20 -0
- package/dist/html-editor/commands/RemoveFormat.js.map +1 -0
- package/dist/html-editor/commands/Separator.d.ts +2 -0
- package/dist/html-editor/commands/Separator.d.ts.map +1 -0
- package/dist/html-editor/commands/Separator.js +29 -0
- package/dist/html-editor/commands/Separator.js.map +1 -0
- package/dist/html-editor/commands/StrikeThrough.d.ts +3 -0
- package/dist/html-editor/commands/StrikeThrough.d.ts.map +1 -0
- package/dist/html-editor/commands/StrikeThrough.js +20 -0
- package/dist/html-editor/commands/StrikeThrough.js.map +1 -0
- package/dist/html-editor/commands/Underline.d.ts +3 -0
- package/dist/html-editor/commands/Underline.d.ts.map +1 -0
- package/dist/html-editor/commands/Underline.js +20 -0
- package/dist/html-editor/commands/Underline.js.map +1 -0
- package/dist/html-editor/commands/Unlink.d.ts +2 -0
- package/dist/html-editor/commands/Unlink.d.ts.map +1 -0
- package/dist/html-editor/commands/Unlink.js +20 -0
- package/dist/html-editor/commands/Unlink.js.map +1 -0
- package/dist/html-editor/commands/UnorderedList.d.ts +2 -0
- package/dist/html-editor/commands/UnorderedList.d.ts.map +1 -0
- package/dist/html-editor/commands/UnorderedList.js +20 -0
- package/dist/html-editor/commands/UnorderedList.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/src/basic/PopupButton.tsx +16 -5
- package/src/html-editor/HtmlEditor.tsx +208 -0
- package/src/html-editor/commands/AddImage.tsx +13 -0
- package/src/html-editor/commands/AddLink.tsx +82 -0
- package/src/html-editor/commands/Align.tsx +32 -0
- package/src/html-editor/commands/Bold.ts +13 -0
- package/src/html-editor/commands/ChangeColor.tsx +178 -0
- package/src/html-editor/commands/ChangeFont.tsx +75 -0
- package/src/html-editor/commands/ChangeFontSize.tsx +18 -0
- package/src/html-editor/commands/Command.tsx +44 -0
- package/src/html-editor/commands/CommandButton.tsx +66 -0
- package/src/html-editor/commands/Headings.tsx +24 -0
- package/src/html-editor/commands/HorizontalRule.tsx +12 -0
- package/src/html-editor/commands/IndentLess.tsx +13 -0
- package/src/html-editor/commands/IndentMore.tsx +13 -0
- package/src/html-editor/commands/Italic.ts +13 -0
- package/src/html-editor/commands/NumberedList.tsx +13 -0
- package/src/html-editor/commands/Quote.tsx +13 -0
- package/src/html-editor/commands/RemoveFormat.tsx +13 -0
- package/src/html-editor/commands/Separator.tsx +18 -0
- package/src/html-editor/commands/StrikeThrough.ts +13 -0
- package/src/html-editor/commands/Underline.ts +13 -0
- package/src/html-editor/commands/Unlink.tsx +13 -0
- package/src/html-editor/commands/UnorderedList.tsx +13 -0
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import Bind from "@web-atoms/core/dist/core/Bind";
|
|
2
|
+
import XNode from "@web-atoms/core/dist/core/XNode";
|
|
3
|
+
import type { HtmlEditorControl } from "../HtmlEditor";
|
|
4
|
+
|
|
5
|
+
export interface ICommandButton {
|
|
6
|
+
icon?: string;
|
|
7
|
+
label?: string;
|
|
8
|
+
/**
|
|
9
|
+
* On click, you must return a promise of string or a string that will be inserted
|
|
10
|
+
*/
|
|
11
|
+
eventInsertHtml?: any;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Default is insertHTML but you can change it.
|
|
15
|
+
*/
|
|
16
|
+
insertCommand: any;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Tooltip
|
|
20
|
+
*/
|
|
21
|
+
title?: string;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function notSet(text: string) {
|
|
25
|
+
return () => {
|
|
26
|
+
alert(`Command ${text} not set`);
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function insert(callback: (s: HtmlEditorControl, e: Event) => Promise<string> | string, command: string): any {
|
|
31
|
+
return async (s: HtmlEditorControl, e: Event) => {
|
|
32
|
+
let r = callback(s, e);
|
|
33
|
+
if (typeof r !== "string") {
|
|
34
|
+
if (r.then) {
|
|
35
|
+
r = await r;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
s.executeCommand(command ?? "insertHTML", false, r as string);
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export default function CommandButton({
|
|
43
|
+
icon,
|
|
44
|
+
label,
|
|
45
|
+
eventInsertHtml,
|
|
46
|
+
insertCommand,
|
|
47
|
+
title
|
|
48
|
+
}: ICommandButton) {
|
|
49
|
+
if (label) {
|
|
50
|
+
return <button
|
|
51
|
+
class="command"
|
|
52
|
+
eventClick={Bind.event(insert(eventInsertHtml, insertCommand))}
|
|
53
|
+
title={title}>
|
|
54
|
+
<label class="label">
|
|
55
|
+
<i class={icon} />
|
|
56
|
+
<span text={label}/>
|
|
57
|
+
</label>
|
|
58
|
+
</button>;
|
|
59
|
+
}
|
|
60
|
+
return <button
|
|
61
|
+
title={title}
|
|
62
|
+
class="command"
|
|
63
|
+
eventClick={Bind.event(insert(eventInsertHtml, insertCommand))}>
|
|
64
|
+
<i class={icon} />
|
|
65
|
+
</button>;
|
|
66
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import Bind from "@web-atoms/core/dist/core/Bind";
|
|
2
|
+
import XNode from "@web-atoms/core/dist/core/XNode";
|
|
3
|
+
import PopupButton, { MenuItem } from "../../basic/PopupButton";
|
|
4
|
+
import type { HtmlEditorControl } from "../HtmlEditor";
|
|
5
|
+
|
|
6
|
+
export default function Headings() {
|
|
7
|
+
return <PopupButton
|
|
8
|
+
class="command"
|
|
9
|
+
icon="ri-heading"
|
|
10
|
+
title="Apply Heading">
|
|
11
|
+
<MenuItem icon="ri-h-1" eventClick={Bind.event((e: HtmlEditorControl) =>
|
|
12
|
+
e.executeCommand("formatBlock", false, "H1"))}/>
|
|
13
|
+
<MenuItem icon="ri-h-2" eventClick={Bind.event((e: any) =>
|
|
14
|
+
e.executeCommand("formatBlock", false, "H2"))}/>
|
|
15
|
+
<MenuItem icon="ri-h-3" eventClick={Bind.event((e: any) =>
|
|
16
|
+
e.executeCommand("formatBlock", false, "H3"))}/>
|
|
17
|
+
<MenuItem icon="ri-h-4" eventClick={Bind.event((e: any) =>
|
|
18
|
+
e.executeCommand("formatBlock", false, "H4"))}/>
|
|
19
|
+
<MenuItem icon="ri-h-5" eventClick={Bind.event((e: any) =>
|
|
20
|
+
e.executeCommand("formatBlock", false, "H5"))}/>
|
|
21
|
+
<MenuItem icon="ri-h-6" eventClick={Bind.event((e: any) =>
|
|
22
|
+
e.executeCommand("formatBlock", false, "H6"))}/>
|
|
23
|
+
</PopupButton>;
|
|
24
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import Command, { ICommand } from "./Command";
|
|
2
|
+
|
|
3
|
+
export default function HorizontalRule(cmd: ICommand) {
|
|
4
|
+
return Command({
|
|
5
|
+
icon: "ri-separator",
|
|
6
|
+
title: "Insert Horizontal Line",
|
|
7
|
+
... cmd,
|
|
8
|
+
command(editor) {
|
|
9
|
+
editor.executeCommand("insertHorizontalRule");
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import Command from "./Command";
|
|
2
|
+
|
|
3
|
+
export default function IndentLess(cmd: any) {
|
|
4
|
+
return Command({
|
|
5
|
+
icon: "ri-indent-decrease",
|
|
6
|
+
queryState: "outdent",
|
|
7
|
+
title: "Indent Less",
|
|
8
|
+
... cmd,
|
|
9
|
+
command(editor) {
|
|
10
|
+
editor.executeCommand("outdent");
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import Command from "./Command";
|
|
2
|
+
|
|
3
|
+
export default function IndentMore(cmd: any) {
|
|
4
|
+
return Command({
|
|
5
|
+
icon: "ri-indent-increase",
|
|
6
|
+
queryState: "indent",
|
|
7
|
+
title: "Indent More",
|
|
8
|
+
... cmd,
|
|
9
|
+
command(editor) {
|
|
10
|
+
editor.executeCommand("indent");
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import Command, { ICommand } from "./Command";
|
|
2
|
+
|
|
3
|
+
export default function Italic(cmd: ICommand) {
|
|
4
|
+
return Command({
|
|
5
|
+
icon: "ri-italic",
|
|
6
|
+
queryState: "italic",
|
|
7
|
+
title: "Italic",
|
|
8
|
+
... cmd,
|
|
9
|
+
command(editor) {
|
|
10
|
+
editor.executeCommand("italic");
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import Command from "./Command";
|
|
2
|
+
|
|
3
|
+
export default function NumberedList(cmd: any) {
|
|
4
|
+
return Command({
|
|
5
|
+
icon: "ri-list-ordered",
|
|
6
|
+
queryState: "insertOrderedList",
|
|
7
|
+
title: "Create Numbered List",
|
|
8
|
+
... cmd,
|
|
9
|
+
command(editor) {
|
|
10
|
+
editor.executeCommand("insertOrderedList");
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import Command from "./Command";
|
|
2
|
+
|
|
3
|
+
export default function IndentMore(cmd: any) {
|
|
4
|
+
return Command({
|
|
5
|
+
icon: "ri-double-quotes",
|
|
6
|
+
queryState: "formatBlock",
|
|
7
|
+
title: "Insert Quote",
|
|
8
|
+
... cmd,
|
|
9
|
+
command(editor) {
|
|
10
|
+
editor.executeCommand("formatBlock");
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import Command from "./Command";
|
|
2
|
+
|
|
3
|
+
export default function RemoveFormat(cmd: any) {
|
|
4
|
+
return Command({
|
|
5
|
+
icon: "ri-format-clear",
|
|
6
|
+
queryState: "removeFormat",
|
|
7
|
+
title: "Clear Formatting",
|
|
8
|
+
... cmd,
|
|
9
|
+
command(editor) {
|
|
10
|
+
editor.executeCommand("removeFormat");
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import Colors from "@web-atoms/core/dist/core/Colors";
|
|
2
|
+
import XNode from "@web-atoms/core/dist/core/XNode";
|
|
3
|
+
import StyleRule from "@web-atoms/core/dist/style/StyleRule";
|
|
4
|
+
import CSS from "@web-atoms/core/dist/web/styles/CSS";
|
|
5
|
+
|
|
6
|
+
const separatorCss = CSS(StyleRule()
|
|
7
|
+
.backgroundColor(Colors.darkGray)
|
|
8
|
+
.marginLeft(4)
|
|
9
|
+
.marginRight(4)
|
|
10
|
+
.display("inline-block")
|
|
11
|
+
.marginTop(4)
|
|
12
|
+
.height(20)
|
|
13
|
+
.width(2)
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
export default function Separator() {
|
|
17
|
+
return <div class={separatorCss}></div>;
|
|
18
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import Command, { ICommand } from "./Command";
|
|
2
|
+
|
|
3
|
+
export default function StrikeThrough(cmd: ICommand) {
|
|
4
|
+
return Command({
|
|
5
|
+
icon: "ri-strikethrough",
|
|
6
|
+
queryState: "strikeThrough",
|
|
7
|
+
title: "Strike Through",
|
|
8
|
+
... cmd,
|
|
9
|
+
command(editor) {
|
|
10
|
+
editor.executeCommand("strikeThrough");
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import Command, { ICommand } from "./Command";
|
|
2
|
+
|
|
3
|
+
export default function Underline(cmd: ICommand) {
|
|
4
|
+
return Command({
|
|
5
|
+
icon: "ri-underline",
|
|
6
|
+
queryState: "underline",
|
|
7
|
+
title: "Underline",
|
|
8
|
+
... cmd,
|
|
9
|
+
command(editor) {
|
|
10
|
+
editor.executeCommand("underline");
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import Command from "./Command";
|
|
2
|
+
|
|
3
|
+
export default function Unlink(cmd: any) {
|
|
4
|
+
return Command({
|
|
5
|
+
icon: "ri-link-unlink-m",
|
|
6
|
+
queryState: "unlink",
|
|
7
|
+
title: "Remove Link",
|
|
8
|
+
... cmd,
|
|
9
|
+
command(editor) {
|
|
10
|
+
editor.executeCommand("unlink");
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import Command from "./Command";
|
|
2
|
+
|
|
3
|
+
export default function UnorderedList(cmd: any) {
|
|
4
|
+
return Command({
|
|
5
|
+
icon: "ri-list-unordered",
|
|
6
|
+
queryState: "insertUnorderedList",
|
|
7
|
+
title: "Create List",
|
|
8
|
+
... cmd,
|
|
9
|
+
command(editor) {
|
|
10
|
+
editor.executeCommand("insertUnorderedList");
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
}
|