@sealcode/jdd-editor 0.2.15 → 0.2.16
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/.nyc_output/51efb67f-ce86-4cce-8246-d293600e6ff2.json +1 -0
- package/.nyc_output/processinfo/0553c492-d66d-4588-be20-d4a284e17ff7.json +1 -0
- package/.nyc_output/processinfo/15c7e9a9-1ea9-4c86-8310-45fa6fc6e38b.json +1 -0
- package/.nyc_output/processinfo/51efb67f-ce86-4cce-8246-d293600e6ff2.json +1 -0
- package/.nyc_output/processinfo/index.json +1 -1
- package/.xunit +1 -1
- package/@types/components.sreact.d.ts +1 -1
- package/@types/controllers/code-snippet.stimulus.d.ts +6 -0
- package/@types/controllers/json-editor.stimulus.d.ts +0 -1
- package/@types/inputs/component-input-code-with-custom-language.d.ts +7 -0
- package/@types/inputs/component-input-code.d.ts +3 -1
- package/@types/inputs/component-input-list.d.ts +3 -2
- package/@types/inputs/component-input-structured.d.ts +3 -2
- package/@types/inputs/component-input-table.d.ts +3 -2
- package/@types/inputs/component-input.d.ts +3 -2
- package/@types/jdd-creator.d.ts +2 -2
- package/assets/styles/components.jdd-page.css +4 -2
- package/coverage/clover.xml +173 -170
- package/dist/src/controllers/code-snippet.stimulus.js +12 -0
- package/dist/src/controllers/code-snippet.stimulus.js.map +7 -0
- package/dist/src/controllers/exportable-textarea.stimulus.js +0 -1
- package/dist/src/controllers/exportable-textarea.stimulus.js.map +2 -2
- package/dist/src/controllers/json-editor.stimulus.js +0 -3
- package/dist/src/controllers/json-editor.stimulus.js.map +2 -2
- package/dist/src/inputs/component-input-code-with-custom-language.js +41 -0
- package/dist/src/inputs/component-input-code-with-custom-language.js.map +7 -0
- package/dist/src/inputs/component-input-code.js +22 -11
- package/dist/src/inputs/component-input-code.js.map +2 -2
- package/dist/src/inputs/component-input-list.js +3 -1
- package/dist/src/inputs/component-input-list.js.map +2 -2
- package/dist/src/inputs/component-input-structured.js +2 -0
- package/dist/src/inputs/component-input-structured.js.map +2 -2
- package/dist/src/inputs/component-input-table.js +6 -3
- package/dist/src/inputs/component-input-table.js.map +2 -2
- package/dist/src/inputs/component-input.js +22 -6
- package/dist/src/inputs/component-input.js.map +2 -2
- package/dist/src/jdd-page.js +2 -1
- package/dist/src/jdd-page.js.map +2 -2
- package/package.json +2 -2
- package/src/controllers/code-snippet.stimulus.ts +12 -0
- package/src/controllers/exportable-textarea.stimulus.ts +0 -1
- package/src/controllers/json-editor.stimulus.ts +0 -4
- package/src/inputs/component-input-code-with-custom-language.ts +44 -0
- package/src/inputs/component-input-code.ts +23 -10
- package/src/inputs/component-input-list.ts +9 -1
- package/src/inputs/component-input-structured.ts +4 -0
- package/src/inputs/component-input-table.ts +5 -1
- package/src/inputs/component-input.ts +31 -1
- package/src/jdd-page.ts +1 -0
- package/.nyc_output/b318e449-cc0d-49b3-8647-15d9173f5905.json +0 -1
- package/.nyc_output/processinfo/65a49023-1c6a-4217-ab3e-89a09cde8bfc.json +0 -1
- package/.nyc_output/processinfo/b318e449-cc0d-49b3-8647-15d9173f5905.json +0 -1
- package/.nyc_output/processinfo/be222db4-3db9-4c08-a4b5-58673c1c7c29.json +0 -1
- /package/.nyc_output/{65a49023-1c6a-4217-ab3e-89a09cde8bfc.json → 0553c492-d66d-4588-be20-d4a284e17ff7.json} +0 -0
- /package/.nyc_output/{be222db4-3db9-4c08-a4b5-58673c1c7c29.json → 15c7e9a9-1ea9-4c86-8310-45fa6fc6e38b.json} +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sealcode/jdd-editor",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.16",
|
|
4
4
|
"main": "dist/src/index.js",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build": "rm -rf dist && node ./esbuild.cjs",
|
|
@@ -47,7 +47,7 @@
|
|
|
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.6",
|
|
51
51
|
"@sealcode/monaco-wrapper": "^0.0.3",
|
|
52
52
|
"@sealcode/sealcodemirror": "^5.70.0-beta5",
|
|
53
53
|
"@sealcode/sealgen": "^0.19.6",
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Controller } from "stimulus";
|
|
2
|
+
|
|
3
|
+
export default class CodeSnippet extends Controller {
|
|
4
|
+
declare codeTarget: HTMLElement;
|
|
5
|
+
|
|
6
|
+
static targets = ["code"];
|
|
7
|
+
|
|
8
|
+
copyCode() {
|
|
9
|
+
const value = this.codeTarget.textContent || "";
|
|
10
|
+
void navigator.clipboard.writeText(value);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -17,7 +17,6 @@ function download(data: string, filename: string, type: string) {
|
|
|
17
17
|
|
|
18
18
|
export default class ExportableTextarea extends Controller<HTMLDetailsElement> {
|
|
19
19
|
connect() {
|
|
20
|
-
console.log("exportable", this.element);
|
|
21
20
|
this.element.removeAttribute("open");
|
|
22
21
|
this.element.addEventListener(
|
|
23
22
|
"turbo:before-morph-attribute",
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { tempstream } from "tempstream";
|
|
2
|
+
import { printArgPath } from "./print-arg-path.js";
|
|
3
|
+
import { is, predicates } from "@sealcode/ts-predicates";
|
|
4
|
+
import { Component } from "@sealcode/jdd";
|
|
5
|
+
|
|
6
|
+
export function ComponentInputCodeWithCustomLanguage({
|
|
7
|
+
language,
|
|
8
|
+
code,
|
|
9
|
+
arg_path,
|
|
10
|
+
component,
|
|
11
|
+
}: {
|
|
12
|
+
code: string;
|
|
13
|
+
language: string;
|
|
14
|
+
arg_path: string[];
|
|
15
|
+
component: Component;
|
|
16
|
+
}): JSX.Element {
|
|
17
|
+
return tempstream /* HTML */ `<div
|
|
18
|
+
id="monaco__${arg_path.join("_")}__for__${component.name}"
|
|
19
|
+
>
|
|
20
|
+
<div data-controller="monaco" data-turbo-permanent="true">
|
|
21
|
+
<input
|
|
22
|
+
data-monaco-target="languageInput"
|
|
23
|
+
data-action="monaco#languageChange"
|
|
24
|
+
type="text"
|
|
25
|
+
name="${`$${printArgPath(arg_path)}`}[language]"
|
|
26
|
+
value="${is(language, predicates.string) ? language : ""}"
|
|
27
|
+
size="40"
|
|
28
|
+
/>
|
|
29
|
+
<div class="monaco-wrapper">
|
|
30
|
+
<textarea
|
|
31
|
+
data-monaco-target="textarea"
|
|
32
|
+
name="$${printArgPath(arg_path)}[code]"
|
|
33
|
+
style="display: none"
|
|
34
|
+
>
|
|
35
|
+
${code}</textarea
|
|
36
|
+
>
|
|
37
|
+
<div
|
|
38
|
+
data-monaco-target="wrapper"
|
|
39
|
+
data-language="${language}"
|
|
40
|
+
></div>
|
|
41
|
+
</div>
|
|
42
|
+
</div>
|
|
43
|
+
</div>`;
|
|
44
|
+
}
|
|
@@ -1,24 +1,37 @@
|
|
|
1
1
|
import { tempstream } from "tempstream";
|
|
2
2
|
import { printArgPath } from "./print-arg-path.js";
|
|
3
|
+
import { Component } from "@sealcode/jdd";
|
|
3
4
|
|
|
4
5
|
export function ComponentInputCode({
|
|
5
6
|
language,
|
|
6
7
|
value,
|
|
7
8
|
arg_path,
|
|
9
|
+
component,
|
|
8
10
|
}: {
|
|
9
11
|
value: string;
|
|
10
12
|
language: string;
|
|
11
13
|
arg_path: string[];
|
|
14
|
+
component: Component;
|
|
12
15
|
}): JSX.Element {
|
|
13
|
-
return tempstream /* HTML */ `<div
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
16
|
+
return tempstream /* HTML */ `<div
|
|
17
|
+
id="monaco__${arg_path.join("_")}__for__${component.name}"
|
|
18
|
+
>
|
|
19
|
+
<div data-controller="monaco">
|
|
20
|
+
<div class="monaco-wrapper">
|
|
21
|
+
<textarea
|
|
22
|
+
data-monaco-target="textarea"
|
|
23
|
+
name="$${printArgPath(arg_path)}"
|
|
24
|
+
style="display: none"
|
|
25
|
+
>
|
|
26
|
+
${value}</textarea
|
|
27
|
+
>
|
|
28
|
+
<div
|
|
29
|
+
data-monaco-target="wrapper"
|
|
30
|
+
data-language="${language}"
|
|
31
|
+
data-turbo-permanent="true"
|
|
32
|
+
id="${arg_path.join("_")}"
|
|
33
|
+
></div>
|
|
34
|
+
</div>
|
|
22
35
|
</div>
|
|
23
|
-
</div
|
|
36
|
+
</div> `;
|
|
24
37
|
}
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-non-null-assertion */
|
|
2
2
|
import type { Context } from "koa";
|
|
3
|
-
import type {
|
|
3
|
+
import type {
|
|
4
|
+
Component,
|
|
5
|
+
ComponentArgument,
|
|
6
|
+
JDDContext,
|
|
7
|
+
List,
|
|
8
|
+
} from "@sealcode/jdd";
|
|
4
9
|
import type { JDDPageState } from "../jdd-page.js";
|
|
5
10
|
import type { StatefulPage } from "@sealcode/sealgen";
|
|
6
11
|
import { ComponentInput } from "./component-input.js";
|
|
@@ -18,6 +23,7 @@ export async function ComponentInputList<
|
|
|
18
23
|
value,
|
|
19
24
|
page,
|
|
20
25
|
makeJDDContext,
|
|
26
|
+
component,
|
|
21
27
|
...rest
|
|
22
28
|
}: {
|
|
23
29
|
state: State;
|
|
@@ -29,6 +35,7 @@ export async function ComponentInputList<
|
|
|
29
35
|
page: StatefulPage<JDDPageState, typeof ComponentPreviewActions>;
|
|
30
36
|
makeJDDContext: (ctx: Context) => JDDContext;
|
|
31
37
|
makeAssetURL: (asset: string) => string;
|
|
38
|
+
component: Component;
|
|
32
39
|
}): Promise<string> {
|
|
33
40
|
if (!value) {
|
|
34
41
|
value = [];
|
|
@@ -49,6 +56,7 @@ export async function ComponentInputList<
|
|
|
49
56
|
value,
|
|
50
57
|
page,
|
|
51
58
|
makeJDDContext,
|
|
59
|
+
component,
|
|
52
60
|
})}
|
|
53
61
|
${page.makeActionButton(
|
|
54
62
|
state,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Context } from "koa";
|
|
2
2
|
import {
|
|
3
|
+
Component,
|
|
3
4
|
Structured,
|
|
4
5
|
type ComponentArgument,
|
|
5
6
|
type JDDContext,
|
|
@@ -22,6 +23,7 @@ export async function ComponentInputStructured<
|
|
|
22
23
|
value,
|
|
23
24
|
page,
|
|
24
25
|
makeJDDContext,
|
|
26
|
+
component,
|
|
25
27
|
...rest
|
|
26
28
|
}: {
|
|
27
29
|
state: JDDPageState;
|
|
@@ -32,6 +34,7 @@ export async function ComponentInputStructured<
|
|
|
32
34
|
page: StatefulPage<JDDPageState, typeof ComponentPreviewActions>;
|
|
33
35
|
makeJDDContext: (ctx: Context) => JDDContext;
|
|
34
36
|
makeAssetURL: (asset: string) => string;
|
|
37
|
+
component: Component;
|
|
35
38
|
}) {
|
|
36
39
|
const structure =
|
|
37
40
|
arg instanceof Structured
|
|
@@ -61,6 +64,7 @@ export async function ComponentInputStructured<
|
|
|
61
64
|
value: value[inner_arg_name],
|
|
62
65
|
page,
|
|
63
66
|
makeJDDContext,
|
|
67
|
+
component,
|
|
64
68
|
...rest,
|
|
65
69
|
})}
|
|
66
70
|
</div>`;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-non-null-assertion */
|
|
2
|
-
import type { JDDContext, Table, TableData } from "@sealcode/jdd";
|
|
2
|
+
import type { Component, JDDContext, Table, TableData } from "@sealcode/jdd";
|
|
3
3
|
import { Markdown } from "@sealcode/jdd";
|
|
4
4
|
import { isTableHeader } from "@sealcode/jdd";
|
|
5
5
|
import type { StatefulPage } from "@sealcode/sealgen";
|
|
@@ -22,6 +22,7 @@ export async function ComponentInputTable<
|
|
|
22
22
|
page,
|
|
23
23
|
makeJDDContext,
|
|
24
24
|
makeAssetURL,
|
|
25
|
+
component,
|
|
25
26
|
}: {
|
|
26
27
|
state: State;
|
|
27
28
|
ctx: Context;
|
|
@@ -31,6 +32,7 @@ export async function ComponentInputTable<
|
|
|
31
32
|
page: StatefulPage<JDDPageState, typeof ComponentPreviewActions>;
|
|
32
33
|
makeJDDContext: (ctx: Context) => JDDContext;
|
|
33
34
|
makeAssetURL: (asset: string) => string;
|
|
35
|
+
component: Component;
|
|
34
36
|
}): Promise<string> {
|
|
35
37
|
if (!value) {
|
|
36
38
|
value = await arg.getEmptyValue(makeJDDContext(ctx));
|
|
@@ -165,6 +167,7 @@ export async function ComponentInputTable<
|
|
|
165
167
|
page,
|
|
166
168
|
makeJDDContext,
|
|
167
169
|
makeAssetURL,
|
|
170
|
+
component,
|
|
168
171
|
})}
|
|
169
172
|
</th>`
|
|
170
173
|
: row.cells.map(
|
|
@@ -185,6 +188,7 @@ export async function ComponentInputTable<
|
|
|
185
188
|
page,
|
|
186
189
|
makeJDDContext,
|
|
187
190
|
makeAssetURL,
|
|
191
|
+
component,
|
|
188
192
|
})}
|
|
189
193
|
</td>`
|
|
190
194
|
)}
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import type { FilePointer } from "@sealcode/file-manager";
|
|
2
|
-
import type {
|
|
2
|
+
import type {
|
|
3
|
+
Component,
|
|
4
|
+
ComponentArgument,
|
|
5
|
+
JDDContext,
|
|
6
|
+
TableData,
|
|
7
|
+
} from "@sealcode/jdd";
|
|
3
8
|
import {
|
|
4
9
|
Code,
|
|
5
10
|
Color,
|
|
@@ -11,6 +16,7 @@ import {
|
|
|
11
16
|
SingleReference,
|
|
12
17
|
Structured,
|
|
13
18
|
Table,
|
|
19
|
+
CodeWithCustomLanguage,
|
|
14
20
|
} from "@sealcode/jdd";
|
|
15
21
|
import type { StatefulPage } from "@sealcode/sealgen";
|
|
16
22
|
import { is, predicates } from "@sealcode/ts-predicates";
|
|
@@ -30,6 +36,8 @@ import { ComponentInputStructured } from "./component-input-structured.js";
|
|
|
30
36
|
import { ComponentInputTable } from "./component-input-table.js";
|
|
31
37
|
import { printArgPath } from "./print-arg-path.js";
|
|
32
38
|
|
|
39
|
+
import { ComponentInputCodeWithCustomLanguage } from "./component-input-code-with-custom-language.js";
|
|
40
|
+
|
|
33
41
|
export const actionName = "Components";
|
|
34
42
|
const absoluteUrlPattern = "http(s?)(://)((www.)?)(([^.]+).)?([a-zA-z0-9-_]+)";
|
|
35
43
|
|
|
@@ -42,6 +50,7 @@ export async function ComponentInput<State extends JDDPageState, T>({
|
|
|
42
50
|
page,
|
|
43
51
|
makeJDDContext,
|
|
44
52
|
makeAssetURL,
|
|
53
|
+
component,
|
|
45
54
|
}: {
|
|
46
55
|
state: State;
|
|
47
56
|
ctx: Context;
|
|
@@ -51,6 +60,7 @@ export async function ComponentInput<State extends JDDPageState, T>({
|
|
|
51
60
|
page: StatefulPage<JDDPageState, typeof ComponentPreviewActions>;
|
|
52
61
|
makeJDDContext: (ctx: Context) => JDDContext;
|
|
53
62
|
makeAssetURL: (asset: string) => string;
|
|
63
|
+
component: Component;
|
|
54
64
|
}): Promise<string> {
|
|
55
65
|
if (value === undefined) {
|
|
56
66
|
value = await arg.getEmptyValue(makeJDDContext(ctx));
|
|
@@ -80,6 +90,7 @@ export async function ComponentInput<State extends JDDPageState, T>({
|
|
|
80
90
|
page,
|
|
81
91
|
makeJDDContext,
|
|
82
92
|
makeAssetURL,
|
|
93
|
+
component,
|
|
83
94
|
});
|
|
84
95
|
}
|
|
85
96
|
|
|
@@ -92,6 +103,22 @@ export async function ComponentInput<State extends JDDPageState, T>({
|
|
|
92
103
|
arg instanceof ComponentArguments.URL && arg.urlType === "absolute";
|
|
93
104
|
const inputType = isUrlAbsolute ? "url" : "text";
|
|
94
105
|
|
|
106
|
+
if (arg instanceof CodeWithCustomLanguage) {
|
|
107
|
+
const valueCasted = value as {
|
|
108
|
+
language: string;
|
|
109
|
+
code: string;
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
return ComponentInputCodeWithCustomLanguage({
|
|
113
|
+
language: valueCasted.language,
|
|
114
|
+
code: is(valueCasted.code, predicates.string)
|
|
115
|
+
? valueCasted.code
|
|
116
|
+
: "",
|
|
117
|
+
arg_path,
|
|
118
|
+
component,
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
|
|
95
122
|
if (arg instanceof Structured || arg instanceof NestedComponent) {
|
|
96
123
|
return ComponentInputStructured({
|
|
97
124
|
ctx,
|
|
@@ -103,6 +130,7 @@ export async function ComponentInput<State extends JDDPageState, T>({
|
|
|
103
130
|
page,
|
|
104
131
|
makeJDDContext,
|
|
105
132
|
makeAssetURL,
|
|
133
|
+
component,
|
|
106
134
|
});
|
|
107
135
|
}
|
|
108
136
|
|
|
@@ -155,6 +183,7 @@ export async function ComponentInput<State extends JDDPageState, T>({
|
|
|
155
183
|
page,
|
|
156
184
|
makeJDDContext,
|
|
157
185
|
makeAssetURL,
|
|
186
|
+
component,
|
|
158
187
|
});
|
|
159
188
|
}
|
|
160
189
|
|
|
@@ -163,6 +192,7 @@ export async function ComponentInput<State extends JDDPageState, T>({
|
|
|
163
192
|
language: arg.language,
|
|
164
193
|
value: is(value, predicates.string) ? value : "",
|
|
165
194
|
arg_path,
|
|
195
|
+
component,
|
|
166
196
|
});
|
|
167
197
|
}
|
|
168
198
|
|