@sealcode/jdd-editor 0.2.4 → 0.2.7
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/inputs/component-input-code.d.ts +5 -0
- package/@types/inputs/component-input-enum.d.ts +3 -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 +23 -0
- package/dist/src/inputs/component-input-code.js.map +7 -0
- package/dist/src/inputs/component-input-color.js.map +1 -1
- package/dist/src/inputs/component-input-enum.js +8 -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 +13 -3
- 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 +6 -4
- package/src/component-preview-actions.ts +2 -3
- package/src/components.sreact.ts +9 -8
- package/src/inputs/component-input-code.ts +24 -0
- package/src/inputs/component-input-color.ts +1 -1
- package/src/inputs/component-input-enum.ts +12 -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 +15 -4
- package/src/jdd-creator.ts +1 -1
- package/src/jdd-page.ts +22 -13
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>
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { tempstream } from "tempstream";
|
|
2
|
+
import { printArgPath } from "./print-arg-path.js";
|
|
3
|
+
|
|
4
|
+
export function ComponentInputCode({
|
|
5
|
+
language,
|
|
6
|
+
value,
|
|
7
|
+
arg_path,
|
|
8
|
+
}: {
|
|
9
|
+
value: string;
|
|
10
|
+
language: string;
|
|
11
|
+
arg_path: string[];
|
|
12
|
+
}): JSX.Element {
|
|
13
|
+
return tempstream /* HTML */ `<div class="monaco-wrapper">
|
|
14
|
+
<div data-controller="monaco" data-language="${language}">
|
|
15
|
+
<textarea
|
|
16
|
+
data-monaco-target="textarea"
|
|
17
|
+
name="$${printArgPath(arg_path)}"
|
|
18
|
+
style="display: none"
|
|
19
|
+
>
|
|
20
|
+
${value}
|
|
21
|
+
</textarea>
|
|
22
|
+
</div>
|
|
23
|
+
</div>`;
|
|
24
|
+
}
|
|
@@ -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,4 +1,4 @@
|
|
|
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
3
|
|
|
4
4
|
export function ComponentInputEnum<State, S extends string, T extends Enum<S>>({
|
|
@@ -6,12 +6,14 @@ export function ComponentInputEnum<State, S extends string, T extends Enum<S>>({
|
|
|
6
6
|
arg,
|
|
7
7
|
value,
|
|
8
8
|
onchange,
|
|
9
|
+
jdd_context,
|
|
9
10
|
}: {
|
|
10
11
|
state: State;
|
|
11
12
|
arg_path: string[];
|
|
12
13
|
arg: T;
|
|
13
14
|
value: string;
|
|
14
15
|
onchange?: string;
|
|
16
|
+
jdd_context: JDDContext;
|
|
15
17
|
}) {
|
|
16
18
|
return /* HTML */ `<div id=${`component-input-enum-${arg_path.join("-")}`}>
|
|
17
19
|
<label>
|
|
@@ -20,14 +22,16 @@ export function ComponentInputEnum<State, S extends string, T extends Enum<S>>({
|
|
|
20
22
|
name="${`$${printArgPath(arg_path)}`}"
|
|
21
23
|
onchange="${onchange || ""}"
|
|
22
24
|
>
|
|
23
|
-
${arg
|
|
25
|
+
${arg
|
|
26
|
+
.getValues(jdd_context)
|
|
24
27
|
.map(
|
|
25
|
-
(v: S) =>
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
(v: S) =>
|
|
29
|
+
/* HTML */ `<option
|
|
30
|
+
value="${v}"
|
|
31
|
+
${value == v ? "selected" : ""}
|
|
32
|
+
>
|
|
33
|
+
${v}
|
|
34
|
+
</option>`
|
|
31
35
|
)
|
|
32
36
|
.join("")}
|
|
33
37
|
</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
|
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
List,
|
|
10
10
|
Structured,
|
|
11
11
|
Table,
|
|
12
|
+
Code,
|
|
12
13
|
} from "@sealcode/jdd";
|
|
13
14
|
import { ComponentInputStructured } from "./component-input-structured.js";
|
|
14
15
|
import type { StatefulPage } from "@sealcode/sealgen";
|
|
@@ -22,6 +23,7 @@ import type { FilePointer } from "@sealcode/file-manager";
|
|
|
22
23
|
import { ComponentInputSingleReference } from "./component-input-single-reference.js";
|
|
23
24
|
import { is, predicates } from "@sealcode/ts-predicates";
|
|
24
25
|
import { tempstream } from "tempstream";
|
|
26
|
+
import { ComponentInputCode } from "./component-input-code.js";
|
|
25
27
|
import { ComponentInputColor } from "./component-input-color.js";
|
|
26
28
|
export const actionName = "Components";
|
|
27
29
|
const absoluteUrlPattern = "http(s?)(://)((www.)?)(([^.]+).)?([a-zA-z0-9-_]+)";
|
|
@@ -116,6 +118,7 @@ export async function ComponentInput<State extends JDDPageState, T>({
|
|
|
116
118
|
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
117
119
|
value: value as string,
|
|
118
120
|
onchange: page.rerender(),
|
|
121
|
+
jdd_context: makeJDDContext(ctx),
|
|
119
122
|
});
|
|
120
123
|
}
|
|
121
124
|
|
|
@@ -146,9 +149,17 @@ export async function ComponentInput<State extends JDDPageState, T>({
|
|
|
146
149
|
});
|
|
147
150
|
}
|
|
148
151
|
|
|
152
|
+
if (arg instanceof Code) {
|
|
153
|
+
return ComponentInputCode({
|
|
154
|
+
language: arg.language,
|
|
155
|
+
value: is(value, predicates.string) ? value : "",
|
|
156
|
+
arg_path,
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
|
|
149
160
|
const inputElement = () => {
|
|
150
161
|
if (arg instanceof ComponentArguments.Number) {
|
|
151
|
-
return tempstream/* HTML */ ` <input
|
|
162
|
+
return tempstream /* HTML */ ` <input
|
|
152
163
|
type="number"
|
|
153
164
|
name="${`$${printArgPath(arg_path)}`}"
|
|
154
165
|
value="${(value || "").toString()}"
|
|
@@ -157,7 +168,7 @@ export async function ComponentInput<State extends JDDPageState, T>({
|
|
|
157
168
|
step="${arg.step || ""}"
|
|
158
169
|
/>`;
|
|
159
170
|
} else if (arg instanceof ComponentArguments.URL) {
|
|
160
|
-
return tempstream/* HTML */ ` <input
|
|
171
|
+
return tempstream /* HTML */ ` <input
|
|
161
172
|
type="${isUrlAbsolute ? "url" : "text"}"
|
|
162
173
|
name="${`$${printArgPath(arg_path)}`}"
|
|
163
174
|
value="${(value || "").toString()}"
|
|
@@ -165,7 +176,7 @@ export async function ComponentInput<State extends JDDPageState, T>({
|
|
|
165
176
|
${isUrlAbsolute ? `pattern="${absoluteUrlPattern}"` : ""}
|
|
166
177
|
/>`;
|
|
167
178
|
} else {
|
|
168
|
-
return tempstream/* HTML */ ` <input
|
|
179
|
+
return tempstream /* HTML */ ` <input
|
|
169
180
|
type="${inputType}"
|
|
170
181
|
name="${`$${printArgPath(arg_path)}`}"
|
|
171
182
|
value="${is(value, predicates.string) ? value : ""}"
|
|
@@ -190,7 +201,7 @@ export async function ComponentInput<State extends JDDPageState, T>({
|
|
|
190
201
|
>
|
|
191
202
|
${is(value, predicates.string) ? value : ""}</textarea
|
|
192
203
|
>
|
|
193
|
-
|
|
204
|
+
</div>`
|
|
194
205
|
: await inputElement()}
|
|
195
206
|
</label>
|
|
196
207
|
</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"
|
package/src/jdd-page.ts
CHANGED
|
@@ -10,7 +10,8 @@ import type { FlatTemplatable, Templatable } from "tempstream";
|
|
|
10
10
|
import { tempstream } from "tempstream";
|
|
11
11
|
import { ComponentInput } from "./inputs/component-input.js";
|
|
12
12
|
import { ComponentPreviewActions } from "./component-preview-actions.js";
|
|
13
|
-
import
|
|
13
|
+
import prettier from "prettier";
|
|
14
|
+
import hljs from "highlight.js";
|
|
14
15
|
|
|
15
16
|
export const actionName = "Components";
|
|
16
17
|
|
|
@@ -102,7 +103,7 @@ export default abstract class JDDPage extends StatefulPage<
|
|
|
102
103
|
loadSearchModal: false,
|
|
103
104
|
},
|
|
104
105
|
makeHead: (...args: unknown[]) =>
|
|
105
|
-
tempstream/* HTML */ `${this.defaultHead(...args)}
|
|
106
|
+
tempstream /* HTML */ `${this.defaultHead(...args)}
|
|
106
107
|
<link
|
|
107
108
|
href="/dist/jdd-page.entrypoint.css"
|
|
108
109
|
rel="stylesheet"
|
|
@@ -171,7 +172,7 @@ export default abstract class JDDPage extends StatefulPage<
|
|
|
171
172
|
index: number
|
|
172
173
|
): Promise<FlatTemplatable> {
|
|
173
174
|
const jdd_context = this.makeJDDContext(ctx);
|
|
174
|
-
return tempstream/* HTML */ `<div
|
|
175
|
+
return tempstream /* HTML */ `<div
|
|
175
176
|
class="component-preview-parameters"
|
|
176
177
|
id="${`component-preview-parameters--${index}`}"
|
|
177
178
|
>
|
|
@@ -238,7 +239,7 @@ export default abstract class JDDPage extends StatefulPage<
|
|
|
238
239
|
? await component.convertParsedToStorage(
|
|
239
240
|
this.makeJDDContext(ctx),
|
|
240
241
|
args
|
|
241
|
-
|
|
242
|
+
)
|
|
242
243
|
: {},
|
|
243
244
|
};
|
|
244
245
|
return single_result;
|
|
@@ -318,7 +319,7 @@ export default abstract class JDDPage extends StatefulPage<
|
|
|
318
319
|
}
|
|
319
320
|
|
|
320
321
|
async render(ctx: Context, state: JDDPageState): Promise<string> {
|
|
321
|
-
return tempstream/* HTML */ `<div
|
|
322
|
+
return tempstream /* HTML */ `<div
|
|
322
323
|
class="${["two-column", "component-debugger", ...this.classes].join(" ")}"
|
|
323
324
|
id="component-debugger"
|
|
324
325
|
style="${`--resizable-column-width: ${
|
|
@@ -400,15 +401,16 @@ export default abstract class JDDPage extends StatefulPage<
|
|
|
400
401
|
class="dynamic"
|
|
401
402
|
value="${state.preview_size}"
|
|
402
403
|
selected
|
|
403
|
-
|
|
404
|
+
>
|
|
404
405
|
${state.preview_size} px
|
|
405
|
-
|
|
406
|
+
</option>`
|
|
406
407
|
: ""
|
|
407
408
|
}
|
|
408
409
|
${this.previewSizes.map(
|
|
409
|
-
(size) =>
|
|
410
|
-
${
|
|
411
|
-
|
|
410
|
+
(size) =>
|
|
411
|
+
/* HTML */ `<option value="${size}">
|
|
412
|
+
${`${size} px`}
|
|
413
|
+
</option>`
|
|
412
414
|
)}
|
|
413
415
|
</select>
|
|
414
416
|
<noscript>
|
|
@@ -454,6 +456,15 @@ export default abstract class JDDPage extends StatefulPage<
|
|
|
454
456
|
documentContainerFromParsed(state.components),
|
|
455
457
|
this.makeJDDContext(ctx)
|
|
456
458
|
);
|
|
459
|
+
|
|
460
|
+
const currentComponentPrettified =
|
|
461
|
+
await prettier.format(currentComponent, {
|
|
462
|
+
parser: "html",
|
|
463
|
+
});
|
|
464
|
+
const highlightedHTML = hljs.highlight(
|
|
465
|
+
currentComponentPrettified,
|
|
466
|
+
{ language: "html" }
|
|
467
|
+
).value;
|
|
457
468
|
return /* HTML */ ` <div
|
|
458
469
|
class="jdd-outer-container"
|
|
459
470
|
>
|
|
@@ -462,9 +473,7 @@ export default abstract class JDDPage extends StatefulPage<
|
|
|
462
473
|
</div>
|
|
463
474
|
</div>
|
|
464
475
|
<div class="component-raw-view">
|
|
465
|
-
<pre><code>${
|
|
466
|
-
currentComponent
|
|
467
|
-
)}</code></pre>
|
|
476
|
+
<pre><code>${highlightedHTML}</code></pre>
|
|
468
477
|
</div>`;
|
|
469
478
|
})()}
|
|
470
479
|
</div>
|