@sealcode/jdd-editor 0.2.5 → 0.2.8
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/@types/components.sreact.d.ts +1 -1
- package/@types/inputs/component-input-enum.d.ts +3 -2
- package/@types/inputs/component-input.d.ts +1 -1
- package/@types/jdd-creator.d.ts +2 -2
- package/assets/styles/atom-one-light.css +72 -0
- package/assets/styles/components.jdd-page.css +13 -6
- package/dist/src/component-preview-actions.js +1 -3
- package/dist/src/component-preview-actions.js.map +2 -2
- package/dist/src/components.sreact.js +5 -5
- package/dist/src/components.sreact.js.map +2 -2
- package/dist/src/inputs/component-input-code.js.map +1 -1
- package/dist/src/inputs/component-input-color.js.map +1 -1
- package/dist/src/inputs/component-input-enum.js +9 -7
- package/dist/src/inputs/component-input-enum.js.map +2 -2
- package/dist/src/inputs/component-input-image.js.map +1 -1
- package/dist/src/inputs/component-input-list.js.map +1 -1
- package/dist/src/inputs/component-input-single-reference.js +5 -5
- package/dist/src/inputs/component-input-single-reference.js.map +2 -2
- package/dist/src/inputs/component-input-structured.js.map +2 -2
- package/dist/src/inputs/component-input-table.js +44 -44
- package/dist/src/inputs/component-input-table.js.map +2 -2
- package/dist/src/inputs/component-input.js +19 -15
- package/dist/src/inputs/component-input.js.map +2 -2
- package/dist/src/jdd-creator.js.map +1 -1
- package/dist/src/jdd-page.js +14 -8
- package/dist/src/jdd-page.js.map +2 -2
- package/package.json +5 -4
- package/src/component-preview-actions.ts +2 -3
- package/src/components.sreact.ts +9 -8
- package/src/inputs/component-input-code.ts +1 -1
- package/src/inputs/component-input-color.ts +1 -1
- package/src/inputs/component-input-enum.ts +13 -8
- package/src/inputs/component-input-image.ts +1 -1
- package/src/inputs/component-input-list.ts +2 -2
- package/src/inputs/component-input-single-reference.ts +8 -7
- package/src/inputs/component-input-structured.ts +2 -2
- package/src/inputs/component-input-table.ts +127 -127
- package/src/inputs/component-input.ts +23 -19
- package/src/jdd-creator.ts +1 -1
- package/src/jdd-page.ts +22 -13
- package/.nyc_output/2100f533-71ff-4c0e-81c5-53e05dcac20f.json +0 -1
- package/.nyc_output/ac9c9615-9aa2-4e42-8685-90e92855ba11.json +0 -1
- package/.nyc_output/d0ae4bd5-5f2e-4e32-9403-fb824c49a5f8.json +0 -1
- package/.nyc_output/processinfo/2100f533-71ff-4c0e-81c5-53e05dcac20f.json +0 -1
- package/.nyc_output/processinfo/ac9c9615-9aa2-4e42-8685-90e92855ba11.json +0 -1
- package/.nyc_output/processinfo/d0ae4bd5-5f2e-4e32-9403-fb824c49a5f8.json +0 -1
- package/.nyc_output/processinfo/index.json +0 -1
- package/.xunit +0 -2
- package/coverage/clover.xml +0 -877
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sealcode/jdd-editor",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.8",
|
|
4
4
|
"main": "dist/src/index.js",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build": "rm -rf dist && node ./esbuild.cjs",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"esbuild": "^0.14.10",
|
|
30
30
|
"eslint": "^8.38.0",
|
|
31
31
|
"eslint-config-prettier": "^8.8.0",
|
|
32
|
-
"eslint-plugin-prettier": "^
|
|
32
|
+
"eslint-plugin-prettier": "^5.5.4",
|
|
33
33
|
"eslint-plugin-with-tsc-error": "^0.0.8",
|
|
34
34
|
"fs": "^0.0.1-security",
|
|
35
35
|
"husky": "^9.1.7",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"mri": "^1.2.0",
|
|
38
38
|
"nyc": "^15.1.0",
|
|
39
39
|
"path": "^0.12.7",
|
|
40
|
-
"prettier": "^
|
|
40
|
+
"prettier": "^3.6.2",
|
|
41
41
|
"source-map-support": "^0.5.21",
|
|
42
42
|
"tiny-glob": "^0.2.9",
|
|
43
43
|
"ts-node": "^10.9.1",
|
|
@@ -47,13 +47,14 @@
|
|
|
47
47
|
"types": "./@types/index.d.ts",
|
|
48
48
|
"dependencies": {
|
|
49
49
|
"@koa/router": "^13.1.0",
|
|
50
|
-
"@sealcode/jdd": "^0.8.
|
|
50
|
+
"@sealcode/jdd": "^0.8.3",
|
|
51
51
|
"@sealcode/monaco-wrapper": "^0.0.3",
|
|
52
52
|
"@sealcode/sealcodemirror": "^5.70.0-beta5",
|
|
53
53
|
"@sealcode/sealgen": "^0.19.6",
|
|
54
54
|
"@types/object-path": "^0.11.4",
|
|
55
55
|
"@types/throttle-debounce": "^5.0.2",
|
|
56
56
|
"@types/turndown": "^5.0.5",
|
|
57
|
+
"highlight.js": "^11.11.1",
|
|
57
58
|
"object-path": "^0.11.8",
|
|
58
59
|
"sealious": "^0.21.0",
|
|
59
60
|
"stimulus": "^3.2.2",
|
|
@@ -241,9 +241,8 @@ export const ComponentPreviewActions = (<const>{
|
|
|
241
241
|
row = {
|
|
242
242
|
type: "header",
|
|
243
243
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
244
|
-
header_content:
|
|
245
|
-
jdd_context
|
|
246
|
-
),
|
|
244
|
+
header_content:
|
|
245
|
+
await argument.header_type.getExampleValue(jdd_context),
|
|
247
246
|
};
|
|
248
247
|
} else {
|
|
249
248
|
const cells = [];
|
package/src/components.sreact.ts
CHANGED
|
@@ -22,14 +22,15 @@ export class JDDDebugger extends JDDPage {
|
|
|
22
22
|
>
|
|
23
23
|
${Object.entries(all_components)
|
|
24
24
|
.map(
|
|
25
|
-
([name]) =>
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
25
|
+
([name]) =>
|
|
26
|
+
/* HTML */ `<option
|
|
27
|
+
value="${name}"
|
|
28
|
+
${name == state.components[0]?.component_name
|
|
29
|
+
? "selected"
|
|
30
|
+
: ""}
|
|
31
|
+
>
|
|
32
|
+
${name}
|
|
33
|
+
</option>`
|
|
33
34
|
)
|
|
34
35
|
.join("")}
|
|
35
36
|
</select>
|
|
@@ -10,7 +10,7 @@ export function ComponentInputCode({
|
|
|
10
10
|
language: string;
|
|
11
11
|
arg_path: string[];
|
|
12
12
|
}): JSX.Element {
|
|
13
|
-
return tempstream/* HTML */ `<div class="monaco-wrapper">
|
|
13
|
+
return tempstream /* HTML */ `<div class="monaco-wrapper">
|
|
14
14
|
<div data-controller="monaco" data-language="${language}">
|
|
15
15
|
<textarea
|
|
16
16
|
data-monaco-target="textarea"
|
|
@@ -21,7 +21,7 @@ export function ComponentInputColor<State extends JDDPageState>({
|
|
|
21
21
|
onchange?: string;
|
|
22
22
|
makeJDDContext: (ctx: Context) => JDDContext;
|
|
23
23
|
}): JSX.Element {
|
|
24
|
-
return tempstream/* HTML */ `<div style="margin-bottom: 10px">
|
|
24
|
+
return tempstream /* HTML */ `<div style="margin-bottom: 10px">
|
|
25
25
|
<div>
|
|
26
26
|
<label>
|
|
27
27
|
${arg_path.at(-1) || ""}
|
|
@@ -1,17 +1,20 @@
|
|
|
1
|
-
import type { Enum } from "@sealcode/jdd";
|
|
1
|
+
import type { Enum, JDDContext } from "@sealcode/jdd";
|
|
2
2
|
import { printArgPath } from "./print-arg-path.js";
|
|
3
|
+
import { htmlEscape } from "escape-goat";
|
|
3
4
|
|
|
4
5
|
export function ComponentInputEnum<State, S extends string, T extends Enum<S>>({
|
|
5
6
|
arg_path,
|
|
6
7
|
arg,
|
|
7
8
|
value,
|
|
8
9
|
onchange,
|
|
10
|
+
jdd_context,
|
|
9
11
|
}: {
|
|
10
12
|
state: State;
|
|
11
13
|
arg_path: string[];
|
|
12
14
|
arg: T;
|
|
13
15
|
value: string;
|
|
14
16
|
onchange?: string;
|
|
17
|
+
jdd_context: JDDContext;
|
|
15
18
|
}) {
|
|
16
19
|
return /* HTML */ `<div id=${`component-input-enum-${arg_path.join("-")}`}>
|
|
17
20
|
<label>
|
|
@@ -20,14 +23,16 @@ export function ComponentInputEnum<State, S extends string, T extends Enum<S>>({
|
|
|
20
23
|
name="${`$${printArgPath(arg_path)}`}"
|
|
21
24
|
onchange="${onchange || ""}"
|
|
22
25
|
>
|
|
23
|
-
${arg
|
|
26
|
+
${arg
|
|
27
|
+
.getValues(jdd_context)
|
|
24
28
|
.map(
|
|
25
|
-
(v: S) =>
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
(v: S) =>
|
|
30
|
+
/* HTML */ `<option
|
|
31
|
+
value="${htmlEscape(v)}"
|
|
32
|
+
${value == v ? "selected" : ""}
|
|
33
|
+
>
|
|
34
|
+
${v}
|
|
35
|
+
</option>`
|
|
31
36
|
)
|
|
32
37
|
.join("")}
|
|
33
38
|
</select>
|
|
@@ -26,7 +26,7 @@ export function ComponentInputImage<State extends JDDPageState>({
|
|
|
26
26
|
makeJDDContext: (ctx: Context) => JDDContext;
|
|
27
27
|
}): JSX.Element {
|
|
28
28
|
const jdd_context = makeJDDContext(ctx);
|
|
29
|
-
return tempstream/* HTML */ `<div style="margin-bottom: 10px">
|
|
29
|
+
return tempstream /* HTML */ `<div style="margin-bottom: 10px">
|
|
30
30
|
<label
|
|
31
31
|
style="display: flex; align-items: center; column-gap: 10px;"
|
|
32
32
|
data-controller="input-image-preview"
|
|
@@ -9,7 +9,7 @@ import { tempstream } from "tempstream";
|
|
|
9
9
|
|
|
10
10
|
export async function ComponentInputList<
|
|
11
11
|
State extends JDDPageState,
|
|
12
|
-
T extends ComponentArgument<unknown
|
|
12
|
+
T extends ComponentArgument<unknown>,
|
|
13
13
|
>({
|
|
14
14
|
state,
|
|
15
15
|
ctx,
|
|
@@ -33,7 +33,7 @@ export async function ComponentInputList<
|
|
|
33
33
|
if (!value) {
|
|
34
34
|
value = [];
|
|
35
35
|
}
|
|
36
|
-
return tempstream/* HTML */ `<fieldset
|
|
36
|
+
return tempstream /* HTML */ `<fieldset
|
|
37
37
|
id="${`component-input-list-${arg_path.join("-")}`}"
|
|
38
38
|
>
|
|
39
39
|
<legend>${arg_path.at(-1)!}</legend>
|
|
@@ -5,7 +5,7 @@ import { printArgPath } from "./print-arg-path.js";
|
|
|
5
5
|
export async function ComponentInputSingleReference<
|
|
6
6
|
State,
|
|
7
7
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
8
|
-
T extends SingleReference<any
|
|
8
|
+
T extends SingleReference<any>,
|
|
9
9
|
>({
|
|
10
10
|
ctx,
|
|
11
11
|
arg_path,
|
|
@@ -30,12 +30,13 @@ export async function ComponentInputSingleReference<
|
|
|
30
30
|
${values
|
|
31
31
|
.sort((v1, v2) => (v1.label > v2.label ? 1 : -1))
|
|
32
32
|
.map(
|
|
33
|
-
(v) =>
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
33
|
+
(v) =>
|
|
34
|
+
/* HTML */ `<option
|
|
35
|
+
value="${v.value}"
|
|
36
|
+
${value == v.value ? "selected" : ""}
|
|
37
|
+
>
|
|
38
|
+
${v.label}
|
|
39
|
+
</option>`
|
|
39
40
|
)
|
|
40
41
|
.join("")}
|
|
41
42
|
</select>
|
|
@@ -13,7 +13,7 @@ import type { ComponentPreviewActions } from "../component-preview-actions.js";
|
|
|
13
13
|
export async function ComponentInputStructured<
|
|
14
14
|
T extends
|
|
15
15
|
| Structured<Record<string, ComponentArgument<unknown>>>
|
|
16
|
-
| NestedComponent
|
|
16
|
+
| NestedComponent,
|
|
17
17
|
>({
|
|
18
18
|
state,
|
|
19
19
|
ctx,
|
|
@@ -42,7 +42,7 @@ export async function ComponentInputStructured<
|
|
|
42
42
|
(Object.keys(
|
|
43
43
|
makeJDDContext(ctx).registry.getAll()
|
|
44
44
|
)[0] as string)
|
|
45
|
-
|
|
45
|
+
);
|
|
46
46
|
|
|
47
47
|
return /* HTML */ `<fieldset
|
|
48
48
|
id="${`component-input-structured-${arg_path.join("-")}`}"
|
|
@@ -12,7 +12,7 @@ import type { JDDPageState } from "../jdd-page.js";
|
|
|
12
12
|
export async function ComponentInputTable<
|
|
13
13
|
State extends JDDPageState,
|
|
14
14
|
CellType,
|
|
15
|
-
HeaderType
|
|
15
|
+
HeaderType,
|
|
16
16
|
>({
|
|
17
17
|
state,
|
|
18
18
|
arg_path,
|
|
@@ -40,7 +40,7 @@ export async function ComponentInputTable<
|
|
|
40
40
|
arg.cell_type instanceof Markdown &&
|
|
41
41
|
arg.header_type instanceof Markdown;
|
|
42
42
|
|
|
43
|
-
return tempstream/* HTML */ `<fieldset>
|
|
43
|
+
return tempstream /* HTML */ `<fieldset>
|
|
44
44
|
<legend>${arg_path.at(-1)!}</legend>
|
|
45
45
|
<div>
|
|
46
46
|
${show_paste
|
|
@@ -52,7 +52,7 @@ export async function ComponentInputTable<
|
|
|
52
52
|
"."
|
|
53
53
|
)}"
|
|
54
54
|
data-controller="jdd-table-paste"
|
|
55
|
-
|
|
55
|
+
/>`
|
|
56
56
|
: ""}
|
|
57
57
|
<table
|
|
58
58
|
class="jdd-component-input--table"
|
|
@@ -63,90 +63,92 @@ export async function ComponentInputTable<
|
|
|
63
63
|
<td></td>
|
|
64
64
|
${[...Array(arg.getColumnsCount(value)).keys()]
|
|
65
65
|
.map(
|
|
66
|
-
(column_index) =>
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
"
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
"
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
66
|
+
(column_index) =>
|
|
67
|
+
/* HTML */ `<th
|
|
68
|
+
class="sticky sticky--top subdued"
|
|
69
|
+
>
|
|
70
|
+
${page.makeActionButton(
|
|
71
|
+
state,
|
|
72
|
+
{
|
|
73
|
+
action: "remove_table_column",
|
|
74
|
+
label: "Remove column",
|
|
75
|
+
content: /* HTML */ `<img
|
|
76
|
+
width="20"
|
|
77
|
+
height="20"
|
|
78
|
+
src="${makeAssetURL(
|
|
79
|
+
"icons/table-delete-column.svg"
|
|
80
|
+
)}"
|
|
81
|
+
/>`,
|
|
82
|
+
},
|
|
83
|
+
arg_path,
|
|
84
|
+
column_index
|
|
85
|
+
)}
|
|
86
|
+
${column_index >=
|
|
87
|
+
arg.getColumnsCount(value) - 1
|
|
88
|
+
? ""
|
|
89
|
+
: page.makeActionButton(
|
|
90
|
+
state,
|
|
91
|
+
{
|
|
92
|
+
action: "move_table_column_right",
|
|
93
|
+
label: "Move column to the right",
|
|
94
|
+
content: /* HTML */ `<img
|
|
95
|
+
width="20"
|
|
96
|
+
height="20"
|
|
97
|
+
src="${makeAssetURL(
|
|
98
|
+
"icons/table-move-column-right.svg"
|
|
99
|
+
)}"
|
|
100
|
+
/>`,
|
|
101
|
+
},
|
|
102
|
+
arg_path,
|
|
103
|
+
column_index
|
|
104
|
+
)}
|
|
105
|
+
</th>`
|
|
105
106
|
)
|
|
106
107
|
.join("")}
|
|
107
108
|
</tr>
|
|
108
109
|
${value.rows.map(
|
|
109
|
-
(row, row_index) =>
|
|
110
|
-
|
|
111
|
-
<
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
"
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
"
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
110
|
+
(row, row_index) =>
|
|
111
|
+
tempstream /* HTML */ `<tr>
|
|
112
|
+
<td class="sticky sticky--left subdued">
|
|
113
|
+
<div
|
|
114
|
+
style="display: flex; flex-flow: column; row-gap: 5px;"
|
|
115
|
+
>
|
|
116
|
+
${page.makeActionButton(
|
|
117
|
+
state,
|
|
118
|
+
{
|
|
119
|
+
action: "remove_table_row",
|
|
120
|
+
label: "Remove row",
|
|
121
|
+
content: /* HTML */ `<img
|
|
122
|
+
width="20"
|
|
123
|
+
height="20"
|
|
124
|
+
src="${makeAssetURL(
|
|
125
|
+
"icons/table-delete-row.svg"
|
|
126
|
+
)}"
|
|
127
|
+
/>`,
|
|
128
|
+
},
|
|
129
|
+
arg_path,
|
|
130
|
+
row_index
|
|
131
|
+
)}
|
|
132
|
+
${page.makeActionButton(
|
|
133
|
+
state,
|
|
134
|
+
{
|
|
135
|
+
action: "move_table_row_down",
|
|
136
|
+
label: "Move this row down",
|
|
137
|
+
content: /* HTML */ `<img
|
|
138
|
+
width="20"
|
|
139
|
+
height="20"
|
|
140
|
+
src="${makeAssetURL(
|
|
141
|
+
"icons/table-move-row-down.svg"
|
|
142
|
+
)}"
|
|
143
|
+
/>`,
|
|
144
|
+
},
|
|
145
|
+
arg_path,
|
|
146
|
+
row_index
|
|
147
|
+
)}
|
|
148
|
+
</div>
|
|
149
|
+
</td>
|
|
150
|
+
${isTableHeader(row)
|
|
151
|
+
? /* HTML */ tempstream`<th
|
|
150
152
|
colspan="${arg.getColumnsCount(value).toString()}"
|
|
151
153
|
>
|
|
152
154
|
${ComponentInput({
|
|
@@ -165,52 +167,50 @@ export async function ComponentInputTable<
|
|
|
165
167
|
makeAssetURL,
|
|
166
168
|
})}
|
|
167
169
|
</th>`
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
170
|
+
: row.cells.map(
|
|
171
|
+
(cell, cell_index) =>
|
|
172
|
+
tempstream /* HTML */ `<td>
|
|
173
|
+
${ComponentInput({
|
|
174
|
+
ctx,
|
|
175
|
+
state,
|
|
176
|
+
arg_path: [
|
|
177
|
+
...arg_path,
|
|
178
|
+
"rows",
|
|
179
|
+
row_index.toString(),
|
|
180
|
+
"cells",
|
|
181
|
+
cell_index.toString(),
|
|
182
|
+
],
|
|
183
|
+
arg: arg.cell_type,
|
|
184
|
+
value: cell,
|
|
185
|
+
page,
|
|
186
|
+
makeJDDContext,
|
|
187
|
+
makeAssetURL,
|
|
188
|
+
})}
|
|
189
|
+
</td>`
|
|
190
|
+
)}
|
|
191
|
+
${row_index == 0
|
|
192
|
+
? /* HTML */ `<td
|
|
193
|
+
class="subdued"
|
|
194
|
+
rowspan="${value.rows.length.toString()}"
|
|
195
|
+
>
|
|
196
|
+
${page.makeActionButton(
|
|
175
197
|
state,
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
"
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
198
|
+
{
|
|
199
|
+
action: "add_table_column",
|
|
200
|
+
label: "Add column",
|
|
201
|
+
content: /* HTML */ `<img
|
|
202
|
+
width="20"
|
|
203
|
+
height="20"
|
|
204
|
+
src="${makeAssetURL(
|
|
205
|
+
"icons/table-add-column-right.svg"
|
|
206
|
+
)}"
|
|
207
|
+
/>`,
|
|
208
|
+
},
|
|
209
|
+
arg_path
|
|
210
|
+
)}
|
|
189
211
|
</td>`
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
? /* HTML */ `<td
|
|
193
|
-
class="subdued"
|
|
194
|
-
rowspan="${value.rows.length.toString()}"
|
|
195
|
-
>
|
|
196
|
-
${page.makeActionButton(
|
|
197
|
-
state,
|
|
198
|
-
{
|
|
199
|
-
action: "add_table_column",
|
|
200
|
-
label: "Add column",
|
|
201
|
-
content: /* HTML */ `<img
|
|
202
|
-
width="20"
|
|
203
|
-
height="20"
|
|
204
|
-
src="${makeAssetURL(
|
|
205
|
-
"icons/table-add-column-right.svg"
|
|
206
|
-
)}"
|
|
207
|
-
/>`,
|
|
208
|
-
},
|
|
209
|
-
arg_path
|
|
210
|
-
)}
|
|
211
|
-
</td>`
|
|
212
|
-
: ""}
|
|
213
|
-
</tr>`
|
|
212
|
+
: ""}
|
|
213
|
+
</tr>`
|
|
214
214
|
)}
|
|
215
215
|
<tr>
|
|
216
216
|
<td
|
|
@@ -1,30 +1,33 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type { Context } from "koa";
|
|
1
|
+
import type { FilePointer } from "@sealcode/file-manager";
|
|
3
2
|
import type { ComponentArgument, JDDContext, TableData } from "@sealcode/jdd";
|
|
4
|
-
import { NestedComponent, Color, SingleReference } from "@sealcode/jdd";
|
|
5
3
|
import {
|
|
4
|
+
Code,
|
|
5
|
+
Color,
|
|
6
6
|
ComponentArguments,
|
|
7
7
|
Enum,
|
|
8
8
|
Image,
|
|
9
9
|
List,
|
|
10
|
+
NestedComponent,
|
|
11
|
+
SingleReference,
|
|
10
12
|
Structured,
|
|
11
13
|
Table,
|
|
12
|
-
Code,
|
|
13
14
|
} from "@sealcode/jdd";
|
|
14
|
-
import { ComponentInputStructured } from "./component-input-structured.js";
|
|
15
15
|
import type { StatefulPage } from "@sealcode/sealgen";
|
|
16
|
+
import { is, predicates } from "@sealcode/ts-predicates";
|
|
17
|
+
import { htmlEscape } from "escape-goat";
|
|
18
|
+
import type { Context } from "koa";
|
|
19
|
+
import { tempstream } from "tempstream";
|
|
16
20
|
import type { ComponentPreviewActions } from "../component-preview-actions.js";
|
|
17
|
-
import { ComponentInputList } from "./component-input-list.js";
|
|
18
21
|
import type { JDDPageState } from "../jdd-page.js";
|
|
22
|
+
import { ComponentInputCode } from "./component-input-code.js";
|
|
23
|
+
import { ComponentInputColor } from "./component-input-color.js";
|
|
19
24
|
import { ComponentInputEnum } from "./component-input-enum.js";
|
|
20
25
|
import { ComponentInputImage } from "./component-input-image.js";
|
|
21
|
-
import {
|
|
22
|
-
import type { FilePointer } from "@sealcode/file-manager";
|
|
26
|
+
import { ComponentInputList } from "./component-input-list.js";
|
|
23
27
|
import { ComponentInputSingleReference } from "./component-input-single-reference.js";
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
26
|
-
import {
|
|
27
|
-
import { ComponentInputColor } from "./component-input-color.js";
|
|
28
|
+
import { ComponentInputStructured } from "./component-input-structured.js";
|
|
29
|
+
import { ComponentInputTable } from "./component-input-table.js";
|
|
30
|
+
import { printArgPath } from "./print-arg-path.js";
|
|
28
31
|
export const actionName = "Components";
|
|
29
32
|
const absoluteUrlPattern = "http(s?)(://)((www.)?)(([^.]+).)?([a-zA-z0-9-_]+)";
|
|
30
33
|
|
|
@@ -118,6 +121,7 @@ export async function ComponentInput<State extends JDDPageState, T>({
|
|
|
118
121
|
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
119
122
|
value: value as string,
|
|
120
123
|
onchange: page.rerender(),
|
|
124
|
+
jdd_context: makeJDDContext(ctx),
|
|
121
125
|
});
|
|
122
126
|
}
|
|
123
127
|
|
|
@@ -158,27 +162,27 @@ export async function ComponentInput<State extends JDDPageState, T>({
|
|
|
158
162
|
|
|
159
163
|
const inputElement = () => {
|
|
160
164
|
if (arg instanceof ComponentArguments.Number) {
|
|
161
|
-
return tempstream/* HTML */ ` <input
|
|
165
|
+
return tempstream /* HTML */ ` <input
|
|
162
166
|
type="number"
|
|
163
167
|
name="${`$${printArgPath(arg_path)}`}"
|
|
164
|
-
value="${(value || "").toString()}"
|
|
168
|
+
value="${htmlEscape((value || "").toString())}"
|
|
165
169
|
min="${arg.min || ""}"
|
|
166
170
|
max="${arg.max || ""}"
|
|
167
171
|
step="${arg.step || ""}"
|
|
168
172
|
/>`;
|
|
169
173
|
} else if (arg instanceof ComponentArguments.URL) {
|
|
170
|
-
return tempstream/* HTML */ ` <input
|
|
174
|
+
return tempstream /* HTML */ ` <input
|
|
171
175
|
type="${isUrlAbsolute ? "url" : "text"}"
|
|
172
176
|
name="${`$${printArgPath(arg_path)}`}"
|
|
173
|
-
value="${(value || "").toString()}"
|
|
177
|
+
value="${htmlEscape((value || "").toString())}"
|
|
174
178
|
size="40"
|
|
175
179
|
${isUrlAbsolute ? `pattern="${absoluteUrlPattern}"` : ""}
|
|
176
180
|
/>`;
|
|
177
181
|
} else {
|
|
178
|
-
return tempstream/* HTML */ ` <input
|
|
182
|
+
return tempstream /* HTML */ ` <input
|
|
179
183
|
type="${inputType}"
|
|
180
184
|
name="${`$${printArgPath(arg_path)}`}"
|
|
181
|
-
value="${is(value, predicates.string) ? value : ""}"
|
|
185
|
+
value="${is(value, predicates.string) ? htmlEscape(value) : ""}"
|
|
182
186
|
size="40"
|
|
183
187
|
${isUrlAbsolute ? `pattern="${absoluteUrlPattern}"` : ""}
|
|
184
188
|
/>`;
|
|
@@ -200,7 +204,7 @@ export async function ComponentInput<State extends JDDPageState, T>({
|
|
|
200
204
|
>
|
|
201
205
|
${is(value, predicates.string) ? value : ""}</textarea
|
|
202
206
|
>
|
|
203
|
-
|
|
207
|
+
</div>`
|
|
204
208
|
: await inputElement()}
|
|
205
209
|
</label>
|
|
206
210
|
</div>`;
|
package/src/jdd-creator.ts
CHANGED
|
@@ -64,7 +64,7 @@ export default abstract class JDDCreator extends JDDPage {
|
|
|
64
64
|
const component =
|
|
65
65
|
this.getRegistryComponents()[component_data.component_name];
|
|
66
66
|
const checkbox_id = `component_${component_index}_open`;
|
|
67
|
-
return tempstream/* HTML */ `<div
|
|
67
|
+
return tempstream /* HTML */ `<div
|
|
68
68
|
class="jdd-editor__component-block jdd-editor__component-block--number-${component_index}"
|
|
69
69
|
id="${`jdd-editor__component-block--${component_data.component_name}-${component_index}`}"
|
|
70
70
|
data-component-debugger-target="componentBlock"
|