@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.
Files changed (122) hide show
  1. package/dist/basic/PopupButton.d.ts +3 -1
  2. package/dist/basic/PopupButton.d.ts.map +1 -1
  3. package/dist/basic/PopupButton.js +13 -4
  4. package/dist/basic/PopupButton.js.map +1 -1
  5. package/dist/html-editor/HtmlEditor.d.ts +23 -0
  6. package/dist/html-editor/HtmlEditor.d.ts.map +1 -0
  7. package/dist/html-editor/HtmlEditor.js +208 -0
  8. package/dist/html-editor/HtmlEditor.js.map +1 -0
  9. package/dist/html-editor/commands/AddImage.d.ts +5 -0
  10. package/dist/html-editor/commands/AddImage.d.ts.map +1 -0
  11. package/dist/html-editor/commands/AddImage.js +23 -0
  12. package/dist/html-editor/commands/AddImage.js.map +1 -0
  13. package/dist/html-editor/commands/AddLink.d.ts +4 -0
  14. package/dist/html-editor/commands/AddLink.d.ts.map +1 -0
  15. package/dist/html-editor/commands/AddLink.js +86 -0
  16. package/dist/html-editor/commands/AddLink.js.map +1 -0
  17. package/dist/html-editor/commands/Align.d.ts +2 -0
  18. package/dist/html-editor/commands/Align.d.ts.map +1 -0
  19. package/dist/html-editor/commands/Align.js +24 -0
  20. package/dist/html-editor/commands/Align.js.map +1 -0
  21. package/dist/html-editor/commands/Bold.d.ts +3 -0
  22. package/dist/html-editor/commands/Bold.d.ts.map +1 -0
  23. package/dist/html-editor/commands/Bold.js +20 -0
  24. package/dist/html-editor/commands/Bold.js.map +1 -0
  25. package/dist/html-editor/commands/ChangeColor.d.ts +2 -0
  26. package/dist/html-editor/commands/ChangeColor.d.ts.map +1 -0
  27. package/dist/html-editor/commands/ChangeColor.js +146 -0
  28. package/dist/html-editor/commands/ChangeColor.js.map +1 -0
  29. package/dist/html-editor/commands/ChangeFont.d.ts +6 -0
  30. package/dist/html-editor/commands/ChangeFont.d.ts.map +1 -0
  31. package/dist/html-editor/commands/ChangeFont.js +72 -0
  32. package/dist/html-editor/commands/ChangeFont.js.map +1 -0
  33. package/dist/html-editor/commands/ChangeFontSize.d.ts +3 -0
  34. package/dist/html-editor/commands/ChangeFontSize.d.ts.map +1 -0
  35. package/dist/html-editor/commands/ChangeFontSize.js +22 -0
  36. package/dist/html-editor/commands/ChangeFontSize.js.map +1 -0
  37. package/dist/html-editor/commands/Command.d.ts +12 -0
  38. package/dist/html-editor/commands/Command.d.ts.map +1 -0
  39. package/dist/html-editor/commands/Command.js +43 -0
  40. package/dist/html-editor/commands/Command.js.map +1 -0
  41. package/dist/html-editor/commands/CommandButton.d.ts +19 -0
  42. package/dist/html-editor/commands/CommandButton.d.ts.map +1 -0
  43. package/dist/html-editor/commands/CommandButton.js +53 -0
  44. package/dist/html-editor/commands/CommandButton.js.map +1 -0
  45. package/dist/html-editor/commands/Headings.d.ts +2 -0
  46. package/dist/html-editor/commands/Headings.d.ts.map +1 -0
  47. package/dist/html-editor/commands/Headings.js +26 -0
  48. package/dist/html-editor/commands/Headings.js.map +1 -0
  49. package/dist/html-editor/commands/HorizontalRule.d.ts +3 -0
  50. package/dist/html-editor/commands/HorizontalRule.d.ts.map +1 -0
  51. package/dist/html-editor/commands/HorizontalRule.js +20 -0
  52. package/dist/html-editor/commands/HorizontalRule.js.map +1 -0
  53. package/dist/html-editor/commands/IndentLess.d.ts +2 -0
  54. package/dist/html-editor/commands/IndentLess.d.ts.map +1 -0
  55. package/dist/html-editor/commands/IndentLess.js +20 -0
  56. package/dist/html-editor/commands/IndentLess.js.map +1 -0
  57. package/dist/html-editor/commands/IndentMore.d.ts +2 -0
  58. package/dist/html-editor/commands/IndentMore.d.ts.map +1 -0
  59. package/dist/html-editor/commands/IndentMore.js +20 -0
  60. package/dist/html-editor/commands/IndentMore.js.map +1 -0
  61. package/dist/html-editor/commands/Italic.d.ts +3 -0
  62. package/dist/html-editor/commands/Italic.d.ts.map +1 -0
  63. package/dist/html-editor/commands/Italic.js +20 -0
  64. package/dist/html-editor/commands/Italic.js.map +1 -0
  65. package/dist/html-editor/commands/NumberedList.d.ts +2 -0
  66. package/dist/html-editor/commands/NumberedList.d.ts.map +1 -0
  67. package/dist/html-editor/commands/NumberedList.js +20 -0
  68. package/dist/html-editor/commands/NumberedList.js.map +1 -0
  69. package/dist/html-editor/commands/Quote.d.ts +2 -0
  70. package/dist/html-editor/commands/Quote.d.ts.map +1 -0
  71. package/dist/html-editor/commands/Quote.js +20 -0
  72. package/dist/html-editor/commands/Quote.js.map +1 -0
  73. package/dist/html-editor/commands/RemoveFormat.d.ts +2 -0
  74. package/dist/html-editor/commands/RemoveFormat.d.ts.map +1 -0
  75. package/dist/html-editor/commands/RemoveFormat.js +20 -0
  76. package/dist/html-editor/commands/RemoveFormat.js.map +1 -0
  77. package/dist/html-editor/commands/Separator.d.ts +2 -0
  78. package/dist/html-editor/commands/Separator.d.ts.map +1 -0
  79. package/dist/html-editor/commands/Separator.js +29 -0
  80. package/dist/html-editor/commands/Separator.js.map +1 -0
  81. package/dist/html-editor/commands/StrikeThrough.d.ts +3 -0
  82. package/dist/html-editor/commands/StrikeThrough.d.ts.map +1 -0
  83. package/dist/html-editor/commands/StrikeThrough.js +20 -0
  84. package/dist/html-editor/commands/StrikeThrough.js.map +1 -0
  85. package/dist/html-editor/commands/Underline.d.ts +3 -0
  86. package/dist/html-editor/commands/Underline.d.ts.map +1 -0
  87. package/dist/html-editor/commands/Underline.js +20 -0
  88. package/dist/html-editor/commands/Underline.js.map +1 -0
  89. package/dist/html-editor/commands/Unlink.d.ts +2 -0
  90. package/dist/html-editor/commands/Unlink.d.ts.map +1 -0
  91. package/dist/html-editor/commands/Unlink.js +20 -0
  92. package/dist/html-editor/commands/Unlink.js.map +1 -0
  93. package/dist/html-editor/commands/UnorderedList.d.ts +2 -0
  94. package/dist/html-editor/commands/UnorderedList.d.ts.map +1 -0
  95. package/dist/html-editor/commands/UnorderedList.js +20 -0
  96. package/dist/html-editor/commands/UnorderedList.js.map +1 -0
  97. package/dist/tsconfig.tsbuildinfo +1 -1
  98. package/package.json +2 -2
  99. package/src/basic/PopupButton.tsx +16 -5
  100. package/src/html-editor/HtmlEditor.tsx +208 -0
  101. package/src/html-editor/commands/AddImage.tsx +13 -0
  102. package/src/html-editor/commands/AddLink.tsx +82 -0
  103. package/src/html-editor/commands/Align.tsx +32 -0
  104. package/src/html-editor/commands/Bold.ts +13 -0
  105. package/src/html-editor/commands/ChangeColor.tsx +178 -0
  106. package/src/html-editor/commands/ChangeFont.tsx +75 -0
  107. package/src/html-editor/commands/ChangeFontSize.tsx +18 -0
  108. package/src/html-editor/commands/Command.tsx +44 -0
  109. package/src/html-editor/commands/CommandButton.tsx +66 -0
  110. package/src/html-editor/commands/Headings.tsx +24 -0
  111. package/src/html-editor/commands/HorizontalRule.tsx +12 -0
  112. package/src/html-editor/commands/IndentLess.tsx +13 -0
  113. package/src/html-editor/commands/IndentMore.tsx +13 -0
  114. package/src/html-editor/commands/Italic.ts +13 -0
  115. package/src/html-editor/commands/NumberedList.tsx +13 -0
  116. package/src/html-editor/commands/Quote.tsx +13 -0
  117. package/src/html-editor/commands/RemoveFormat.tsx +13 -0
  118. package/src/html-editor/commands/Separator.tsx +18 -0
  119. package/src/html-editor/commands/StrikeThrough.ts +13 -0
  120. package/src/html-editor/commands/Underline.ts +13 -0
  121. package/src/html-editor/commands/Unlink.tsx +13 -0
  122. 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
+ }