Skip to content

Commit b61922a

Browse files
committed
add checkbox to cancel inserted namespace line
Signed-off-by: Lîm Tsú-thuàn <inbox@dannypsnl.me>
1 parent c827609 commit b61922a

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

app.js

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import van from "vanjs-core";
22
import * as htmlparser2 from "htmlparser2";
33
import { svg as example } from "./example";
44

5-
const { h1, code, button, div, pre, textarea, p } = van.tags;
5+
const { h1, code, button, div, pre, input, textarea, p, label } = van.tags;
66

77
const html2tree = (str) => {
88
let res = ``;
@@ -21,9 +21,10 @@ const html2tree = (str) => {
2121

2222
const App = () => {
2323
const html_input = van.state(example);
24+
const add_xmlns = van.state(true);
2425
const output_tree = van.derive(
2526
() =>
26-
`\\xmlns:html{http://www.w3.org/1999/xhtml}\n\n` +
27+
(add_xmlns.val ? `\\xmlns:html{http://www.w3.org/1999/xhtml}\n\n` : ``) +
2728
html2tree(html_input.val)
2829
);
2930

@@ -32,6 +33,14 @@ const App = () => {
3233
p(
3334
`Put HTML into the textarea, then copy the forester tree right hand side.`
3435
),
36+
input({
37+
type: `checkbox`,
38+
id: `add-namespace`,
39+
onclick: () => {
40+
add_xmlns.val = !add_xmlns.val;
41+
},
42+
}),
43+
label({ for: `add-namespace` }, `disable inserted namespace`),
3544
div(
3645
textarea({
3746
value: html_input,
@@ -43,10 +52,10 @@ const App = () => {
4352
{
4453
onclick: () => {
4554
navigator.clipboard.writeText(output_tree.val);
46-
alert("copied!");
55+
alert(`copied!`);
4756
},
4857
},
49-
"copy"
58+
`copy`
5059
)
5160
)
5261
)

0 commit comments

Comments
 (0)