@web-atoms/web-controls 2.1.9 → 2.1.13
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 +32 -0
- package/dist/basic/FormField.js.map +1 -0
- package/dist/basic/PopupButton.d.ts +2 -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 +25 -0
- package/dist/html-editor/HtmlEditor.d.ts.map +1 -0
- package/dist/html-editor/HtmlEditor.js +240 -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 +93 -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 +55 -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/Source.d.ts +4 -0
- package/dist/html-editor/commands/Source.d.ts.map +1 -0
- package/dist/html-editor/commands/Source.js +72 -0
- package/dist/html-editor/commands/Source.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/FormField.tsx +37 -0
- package/src/basic/PopupButton.tsx +15 -4
- package/src/html-editor/HtmlEditor.tsx +242 -0
- package/src/html-editor/commands/AddImage.tsx +13 -0
- package/src/html-editor/commands/AddLink.tsx +90 -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 +68 -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/Source.tsx +53 -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,75 @@
|
|
|
1
|
+
import Bind from "@web-atoms/core/dist/core/Bind";
|
|
2
|
+
import Colors from "@web-atoms/core/dist/core/Colors";
|
|
3
|
+
import XNode from "@web-atoms/core/dist/core/XNode";
|
|
4
|
+
import StyleRule from "@web-atoms/core/dist/style/StyleRule";
|
|
5
|
+
import CSS from "@web-atoms/core/dist/web/styles/CSS";
|
|
6
|
+
import PopupButton from "../../basic/PopupButton";
|
|
7
|
+
import type { HtmlEditorControl } from "../HtmlEditor";
|
|
8
|
+
|
|
9
|
+
const fontMenuCSS = CSS(StyleRule()
|
|
10
|
+
.padding(5)
|
|
11
|
+
.child(StyleRule(".menu")
|
|
12
|
+
.padding(5)
|
|
13
|
+
.hoverBackgroundColor(Colors.lightGreen)
|
|
14
|
+
.child(StyleRule("i")
|
|
15
|
+
.opacity("0")
|
|
16
|
+
.and(StyleRule(".selected")
|
|
17
|
+
.opacity("1")
|
|
18
|
+
)
|
|
19
|
+
)
|
|
20
|
+
)
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
const fonts = [
|
|
24
|
+
["Sans Serif", ["arial", "sans-serif"]],
|
|
25
|
+
["Serif", [`"times new roman"`, "serif"]],
|
|
26
|
+
["Fixed Width", ["monospace"]],
|
|
27
|
+
["Wide", [`"arial black"`, "sans-serif"]],
|
|
28
|
+
["Narrow", [`"arial narrow"`, "sans-serif"]],
|
|
29
|
+
["Comic Sans MS", [`"comic sans ms"`, "sans-serif"]],
|
|
30
|
+
["Garamond", ["garamond", `"times new roman"`, "serif"]],
|
|
31
|
+
["Georgia", ["georgia"]],
|
|
32
|
+
["Tahoma", ["tahoma"]],
|
|
33
|
+
["Trebuchet MS", [`"trebuchet ms"`]],
|
|
34
|
+
["Verdana", ["verdana"]]
|
|
35
|
+
];
|
|
36
|
+
|
|
37
|
+
export function FontMenu({ name, value }) {
|
|
38
|
+
const cssName = value.join(" ");
|
|
39
|
+
return <div
|
|
40
|
+
class="menu"
|
|
41
|
+
eventClick={Bind.event((e: HtmlEditorControl) => e.executeCommand("fontName", false, cssName) )}>
|
|
42
|
+
<i class={Bind.oneWay((e: HtmlEditorControl) => ({
|
|
43
|
+
"ri-check-line": 1,
|
|
44
|
+
"selected": e.getStyle("fontFamily", e.version)
|
|
45
|
+
.toLowerCase()
|
|
46
|
+
.indexOf(value[0].toLowerCase()) !== -1
|
|
47
|
+
}))}/>
|
|
48
|
+
<label styleFontFamily={name}>{name}</label>
|
|
49
|
+
</div>;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function selectFont(name: string) {
|
|
53
|
+
if (name === null) {
|
|
54
|
+
return "Font";
|
|
55
|
+
}
|
|
56
|
+
for (const [display, value] of fonts) {
|
|
57
|
+
for (const iterator of value) {
|
|
58
|
+
if (name.indexOf(iterator) !== -1) {
|
|
59
|
+
return display;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return "Font";
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export default function ChangeFont() {
|
|
67
|
+
return <PopupButton
|
|
68
|
+
class="command"
|
|
69
|
+
text={Bind.oneWay((e: HtmlEditorControl) => selectFont(e.getStyle("fontFamily", e.version)))}
|
|
70
|
+
title="Change Font">
|
|
71
|
+
<div class={fontMenuCSS}>
|
|
72
|
+
{ ... fonts.map((x) => <FontMenu name={x[0]} value={x[1]}/>)}
|
|
73
|
+
</div>
|
|
74
|
+
</PopupButton>;
|
|
75
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
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
|
+
import Command, { ICommand } from "./Command";
|
|
6
|
+
|
|
7
|
+
export default function ChangeFontSize(cmd: ICommand) {
|
|
8
|
+
return <PopupButton
|
|
9
|
+
class="command"
|
|
10
|
+
icon="ri-font-size-2"
|
|
11
|
+
title="Change Font Size">
|
|
12
|
+
<MenuItem icon="ri-add-line" label="Increase" eventClick={Bind.event((e: HtmlEditorControl) =>
|
|
13
|
+
e.executeCommand("increaseFontSize"))}/>
|
|
14
|
+
<MenuItem icon="ri-subtract-line" label="Decrease" eventClick={Bind.event((e: HtmlEditorControl) =>
|
|
15
|
+
e.executeCommand("decreaseFontSize"))}/>
|
|
16
|
+
</PopupButton>;
|
|
17
|
+
|
|
18
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
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 ICommand {
|
|
6
|
+
label?: string;
|
|
7
|
+
icon?: string;
|
|
8
|
+
queryState?: string;
|
|
9
|
+
enabled?: boolean;
|
|
10
|
+
title?: string;
|
|
11
|
+
command?: (editor: HtmlEditorControl) => void;
|
|
12
|
+
query?: (editor: HtmlEditorControl) => boolean;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export default function Command({
|
|
16
|
+
icon,
|
|
17
|
+
label,
|
|
18
|
+
command,
|
|
19
|
+
queryState = "none",
|
|
20
|
+
query,
|
|
21
|
+
... others
|
|
22
|
+
}: ICommand) {
|
|
23
|
+
if (label) {
|
|
24
|
+
return <div
|
|
25
|
+
eventClick={Bind.event((e) => command(e as HtmlEditorControl))}
|
|
26
|
+
styleClass={Bind.oneWay((e: HtmlEditorControl) => ({
|
|
27
|
+
command: e.version,
|
|
28
|
+
pressed: !e.queryCommandState(queryState)
|
|
29
|
+
}))}
|
|
30
|
+
{ ... others }>
|
|
31
|
+
<i class={icon}/>
|
|
32
|
+
<label class="label" text={label}/>
|
|
33
|
+
</div>;
|
|
34
|
+
}
|
|
35
|
+
return <div
|
|
36
|
+
eventClick={Bind.event((e) => command(e as HtmlEditorControl))}
|
|
37
|
+
styleClass={Bind.oneWay((e: HtmlEditorControl) => ({
|
|
38
|
+
command: e.version,
|
|
39
|
+
pressed: e.queryCommandState(queryState)
|
|
40
|
+
}))}
|
|
41
|
+
{ ... others }>
|
|
42
|
+
<i class={icon}/>
|
|
43
|
+
</div>;
|
|
44
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
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
|
+
if (r) {
|
|
39
|
+
s.executeCommand(command ?? "insertHTML", false, r as string);
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export default function CommandButton({
|
|
45
|
+
icon,
|
|
46
|
+
label,
|
|
47
|
+
eventInsertHtml,
|
|
48
|
+
insertCommand,
|
|
49
|
+
title
|
|
50
|
+
}: ICommandButton) {
|
|
51
|
+
if (label) {
|
|
52
|
+
return <button
|
|
53
|
+
class="command"
|
|
54
|
+
eventClick={Bind.event(insert(eventInsertHtml, insertCommand))}
|
|
55
|
+
title={title}>
|
|
56
|
+
<label class="label">
|
|
57
|
+
<i class={icon} />
|
|
58
|
+
<span text={label}/>
|
|
59
|
+
</label>
|
|
60
|
+
</button>;
|
|
61
|
+
}
|
|
62
|
+
return <button
|
|
63
|
+
title={title}
|
|
64
|
+
class="command"
|
|
65
|
+
eventClick={Bind.event(insert(eventInsertHtml, insertCommand))}>
|
|
66
|
+
<i class={icon} />
|
|
67
|
+
</button>;
|
|
68
|
+
}
|
|
@@ -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,53 @@
|
|
|
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(800)
|
|
13
|
+
.minWidth(800)
|
|
14
|
+
)
|
|
15
|
+
);
|
|
16
|
+
|
|
17
|
+
async function showDialog(s: HtmlEditorControl, e: Event): Promise<string> {
|
|
18
|
+
const popupService = s.app.resolve(PopupService);
|
|
19
|
+
|
|
20
|
+
class SourceDialog extends PopupWindow {
|
|
21
|
+
|
|
22
|
+
@BindableProperty
|
|
23
|
+
public source: string;
|
|
24
|
+
|
|
25
|
+
protected create(): void {
|
|
26
|
+
this.source = s.htmlContent;
|
|
27
|
+
this.render(<div class={css}>
|
|
28
|
+
<textarea value={Bind.twoWaysImmediate(() => this.source)}/>
|
|
29
|
+
<div class="command-bar">
|
|
30
|
+
<button
|
|
31
|
+
eventClick={Bind.event(() => this.viewModel.close(this.source))}
|
|
32
|
+
text="Save"/>
|
|
33
|
+
</div>
|
|
34
|
+
</div>);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const result = await popupService.showWindow(s.element, SourceDialog);
|
|
40
|
+
s.htmlContent = result as string;
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export default function Source({
|
|
45
|
+
insertCommand = "createLink"
|
|
46
|
+
}) {
|
|
47
|
+
return CommandButton({
|
|
48
|
+
icon: "ri-edit-box-fill",
|
|
49
|
+
insertCommand,
|
|
50
|
+
eventInsertHtml: showDialog,
|
|
51
|
+
title: "Create Hyper Link"
|
|
52
|
+
});
|
|
53
|
+
}
|
|
@@ -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
|
+
}
|