@eworkbase/sdk 0.8.3 → 0.8.5
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/{ExecutionLog.dto-ig9GUWhK.d.ts → ExecutionLog.dto-Bq2u5C90.d.ts} +1 -1
- package/dist/index.d.ts +20 -14
- package/dist/index.js +142 -245
- package/dist/markdown.d.ts +1 -1
- package/dist/markdown.js +9 -2
- package/dist/style.css +4 -98
- package/dist/{types-DXhRV5dI.d.ts → types-CPObI29j.d.ts} +41 -4
- package/dist/{types-2X-_T_W_.d.ts → types-WIMkhmH4.d.ts} +29 -101
- package/dist/ui/components.d.ts +55 -0
- package/dist/ui/components.js +131 -0
- package/dist/ui/execution-log.d.ts +6 -2
- package/dist/ui/execution-log.js +11 -20
- package/dist/ui/index.css +38 -165
- package/dist/ui/index.d.ts +24 -2
- package/dist/ui/index.js +96 -22
- package/dist/ui/markdown-links.d.ts +1 -1
- package/dist/ui/markdown-links.js +44 -34
- package/dist/ui/model.d.ts +1 -2
- package/dist/ui/model.js +1 -8
- package/dist/ui/theme.css +123 -1
- package/package.json +27 -7
|
@@ -1,13 +1,31 @@
|
|
|
1
1
|
import { t as parseMarkdownLink } from "../markdown-link-C-qw7xuN.js";
|
|
2
|
-
import { renderMarkdownPreview } from "./markdown-editor.js";
|
|
3
2
|
import { memo, useCallback, useEffect, useId, useRef, useState } from "react";
|
|
4
3
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
4
|
+
import Markdown from "react-markdown";
|
|
5
|
+
import remarkGfm from "remark-gfm";
|
|
5
6
|
//#region src/ui/MarkdownLinks.tsx
|
|
6
7
|
/** Keeps Markdown navigation inside its document context while preserving mounted editors. */
|
|
7
8
|
const MAXIMUM_CACHED_DOCUMENTS = 8;
|
|
8
9
|
const DOCUMENT_SOURCE_SELECTOR = "[data-markdown-source]";
|
|
9
10
|
const HEADING_SELECTOR = "h1,h2,h3,h4,h5,h6";
|
|
10
|
-
const
|
|
11
|
+
const DISALLOWED_PREVIEW_ELEMENTS = [
|
|
12
|
+
"img",
|
|
13
|
+
"iframe",
|
|
14
|
+
"object",
|
|
15
|
+
"embed",
|
|
16
|
+
"audio",
|
|
17
|
+
"video",
|
|
18
|
+
"source",
|
|
19
|
+
"script",
|
|
20
|
+
"style",
|
|
21
|
+
"link",
|
|
22
|
+
"meta",
|
|
23
|
+
"base",
|
|
24
|
+
"form",
|
|
25
|
+
"button"
|
|
26
|
+
];
|
|
27
|
+
const REMARK_PLUGINS = [remarkGfm];
|
|
28
|
+
const PREVIEW_COMPONENTS = { input: DisabledPreviewCheckbox };
|
|
11
29
|
const MarkdownLinks = memo(function MarkdownLinks(props) {
|
|
12
30
|
return /* @__PURE__ */ jsx(MarkdownLinkBoundary, { ...props }, props.contextKey);
|
|
13
31
|
});
|
|
@@ -187,49 +205,41 @@ function MarkdownLinkBoundary({ host, children }) {
|
|
|
187
205
|
}
|
|
188
206
|
const MarkdownPreview = memo(function MarkdownPreview({ document: markdownDocument, onError }) {
|
|
189
207
|
const container = useRef(null);
|
|
190
|
-
const [isRendering, setRendering] = useState(true);
|
|
191
208
|
useEffect(() => {
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
const template = document.createElement("template");
|
|
199
|
-
template.innerHTML = html;
|
|
200
|
-
template.content.querySelectorAll(INACTIVE_PREVIEW_ELEMENTS).forEach((element) => element.remove());
|
|
201
|
-
template.content.querySelectorAll("input[type=\"checkbox\"]").forEach((checkbox) => {
|
|
202
|
-
checkbox.disabled = true;
|
|
203
|
-
});
|
|
204
|
-
container.current.replaceChildren(template.content);
|
|
205
|
-
if (markdownDocument.fragment) scrollToAnchor(container.current, markdownDocument.fragment);
|
|
206
|
-
} catch (failure) {
|
|
207
|
-
if (!stopped) onError(readableError(failure));
|
|
208
|
-
} finally {
|
|
209
|
-
if (!stopped) setRendering(false);
|
|
210
|
-
}
|
|
211
|
-
};
|
|
212
|
-
render();
|
|
213
|
-
return () => {
|
|
214
|
-
stopped = true;
|
|
215
|
-
};
|
|
209
|
+
if (!markdownDocument.fragment || !container.current) return;
|
|
210
|
+
try {
|
|
211
|
+
scrollToAnchor(container.current, markdownDocument.fragment);
|
|
212
|
+
} catch (failure) {
|
|
213
|
+
onError(readableError(failure));
|
|
214
|
+
}
|
|
216
215
|
}, [
|
|
217
216
|
markdownDocument.content,
|
|
218
217
|
markdownDocument.fragment,
|
|
219
218
|
markdownDocument.revision,
|
|
220
219
|
onError
|
|
221
220
|
]);
|
|
222
|
-
return /* @__PURE__ */
|
|
221
|
+
return /* @__PURE__ */ jsx("div", {
|
|
223
222
|
"data-markdown-source": markdownDocument.path,
|
|
224
|
-
children:
|
|
225
|
-
role: "status",
|
|
226
|
-
children: "正在排版文档…"
|
|
227
|
-
}) : null, /* @__PURE__ */ jsx("div", {
|
|
223
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
228
224
|
ref: container,
|
|
229
|
-
className: "markdown-document-body
|
|
230
|
-
|
|
225
|
+
className: "markdown-document-body",
|
|
226
|
+
children: /* @__PURE__ */ jsx(Markdown, {
|
|
227
|
+
remarkPlugins: REMARK_PLUGINS,
|
|
228
|
+
disallowedElements: DISALLOWED_PREVIEW_ELEMENTS,
|
|
229
|
+
skipHtml: true,
|
|
230
|
+
components: PREVIEW_COMPONENTS,
|
|
231
|
+
children: markdownDocument.content
|
|
232
|
+
})
|
|
233
|
+
})
|
|
231
234
|
});
|
|
232
235
|
});
|
|
236
|
+
function DisabledPreviewCheckbox(props) {
|
|
237
|
+
if (props.type === "checkbox") return /* @__PURE__ */ jsx("input", {
|
|
238
|
+
...props,
|
|
239
|
+
disabled: true
|
|
240
|
+
});
|
|
241
|
+
return /* @__PURE__ */ jsx("input", { ...props });
|
|
242
|
+
}
|
|
233
243
|
function scrollToAnchor(root, fragment) {
|
|
234
244
|
if (!root) return;
|
|
235
245
|
if (!fragment) {
|
package/dist/ui/model.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { D as PluginUiToastOptions, j as WorkbasePluginUi } from "../types-CPObI29j.js";
|
|
2
2
|
//#region src/ui/model.d.ts
|
|
3
3
|
/** A notification transport failure must not turn a completed operation into a failed one. */
|
|
4
4
|
export declare function showOperationToast(host: Pick<WorkbasePluginUi, "showToast">, options: PluginUiToastOptions): void;
|
|
@@ -18,7 +18,6 @@ export declare function configurationSavedMessage(publication: {
|
|
|
18
18
|
readonly warning: string | null;
|
|
19
19
|
}): string;
|
|
20
20
|
export declare function formatActionOutput(title: string, result: unknown, logs: unknown): PluginActionOutput;
|
|
21
|
-
export declare function formatActionError(title: string, error: unknown): PluginActionOutput;
|
|
22
21
|
export declare function readableError(error: unknown, fallback: string): string;
|
|
23
22
|
/** Keeps the actual cause visible while leaving stack frames in technical details. */
|
|
24
23
|
export declare function errorSummary(message: string): string;
|
package/dist/ui/model.js
CHANGED
|
@@ -23,13 +23,6 @@ function formatActionOutput(title, result, logs) {
|
|
|
23
23
|
title
|
|
24
24
|
};
|
|
25
25
|
}
|
|
26
|
-
function formatActionError(title, error) {
|
|
27
|
-
return {
|
|
28
|
-
content: readableError(error, `${title}失败。`),
|
|
29
|
-
status: "failed",
|
|
30
|
-
title
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
26
|
function readableError(error, fallback) {
|
|
34
27
|
return error instanceof Error && error.message.trim().length > 0 ? error.message : fallback;
|
|
35
28
|
}
|
|
@@ -54,4 +47,4 @@ function isRecord(value) {
|
|
|
54
47
|
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
55
48
|
}
|
|
56
49
|
//#endregion
|
|
57
|
-
export { ConfigurationMode, TEAM_CONFIGURATION_NOTICE, configurationSavedMessage, errorSummary,
|
|
50
|
+
export { ConfigurationMode, TEAM_CONFIGURATION_NOTICE, configurationSavedMessage, errorSummary, formatActionOutput, readableError, showOperationToast };
|
package/dist/ui/theme.css
CHANGED
|
@@ -81,6 +81,17 @@
|
|
|
81
81
|
|
|
82
82
|
.workbase-brand-control[data-variant="subtle"] { color: var(--color-muted); }
|
|
83
83
|
|
|
84
|
+
.workbase-danger-control:not(:disabled):not([data-disabled]) {
|
|
85
|
+
border-color: var(--color-danger);
|
|
86
|
+
color: var(--color-inverse, #ffffff);
|
|
87
|
+
background: var(--color-danger);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
.workbase-danger-control:active:not(:disabled):not([data-disabled]) {
|
|
91
|
+
background: #902908;
|
|
92
|
+
box-shadow: inset 0 1px 2px rgb(0 0 0 / 18%);
|
|
93
|
+
}
|
|
94
|
+
|
|
84
95
|
.mantine-Button-root:focus-visible,
|
|
85
96
|
.mantine-ActionIcon-root:focus-visible,
|
|
86
97
|
.mantine-Tabs-tab:focus-visible {
|
|
@@ -136,6 +147,11 @@
|
|
|
136
147
|
color: var(--color-brand-deep);
|
|
137
148
|
background: var(--color-surface-muted);
|
|
138
149
|
}
|
|
150
|
+
|
|
151
|
+
.workbase-danger-control:hover:not(:disabled):not([data-disabled]) {
|
|
152
|
+
border-color: #a52f09;
|
|
153
|
+
background: #a52f09;
|
|
154
|
+
}
|
|
139
155
|
}
|
|
140
156
|
|
|
141
157
|
.mantine-Button-root:disabled,
|
|
@@ -295,9 +311,115 @@
|
|
|
295
311
|
.mantine-Switch-track[data-checked] { border-color: var(--color-primary-hover); }
|
|
296
312
|
|
|
297
313
|
.mantine-UnstyledButton-root:focus-visible {
|
|
298
|
-
outline: 2px solid var(--color-
|
|
314
|
+
outline: 2px solid var(--color-accent);
|
|
299
315
|
outline-offset: 2px;
|
|
300
316
|
}
|
|
317
|
+
|
|
318
|
+
.workbase-pill {
|
|
319
|
+
--workbase-pill-color: var(--color-muted);
|
|
320
|
+
display: inline-flex;
|
|
321
|
+
align-items: center;
|
|
322
|
+
gap: 6px;
|
|
323
|
+
width: fit-content;
|
|
324
|
+
min-height: 24px;
|
|
325
|
+
flex-shrink: 0;
|
|
326
|
+
padding: 2px 8px;
|
|
327
|
+
border-radius: 4px;
|
|
328
|
+
color: var(--workbase-pill-color);
|
|
329
|
+
background: color-mix(in srgb, var(--workbase-pill-color) 8%, transparent);
|
|
330
|
+
font-size: var(--workbase-type-meta);
|
|
331
|
+
font-weight: 500;
|
|
332
|
+
line-height: 16px;
|
|
333
|
+
white-space: nowrap;
|
|
334
|
+
}
|
|
335
|
+
.workbase-pill[data-tone="success"] { --workbase-pill-color: var(--color-success); }
|
|
336
|
+
.workbase-pill[data-tone="warning"] { --workbase-pill-color: var(--color-warning); }
|
|
337
|
+
.workbase-pill[data-tone="danger"] { --workbase-pill-color: var(--color-danger); }
|
|
338
|
+
.workbase-pill[data-tone="info"] { --workbase-pill-color: var(--color-accent); }
|
|
339
|
+
.workbase-pill[data-tone="neutral"] { --workbase-pill-color: var(--color-muted); background: transparent; }
|
|
340
|
+
.workbase-pill-dot {
|
|
341
|
+
width: 6px;
|
|
342
|
+
height: 6px;
|
|
343
|
+
flex-shrink: 0;
|
|
344
|
+
border-radius: 50%;
|
|
345
|
+
background: currentColor;
|
|
346
|
+
opacity: 0.8;
|
|
347
|
+
}
|
|
348
|
+
.workbase-pill-spinner {
|
|
349
|
+
width: 11px;
|
|
350
|
+
height: 11px;
|
|
351
|
+
flex-shrink: 0;
|
|
352
|
+
border: 1.5px solid color-mix(in srgb, currentColor 28%, transparent);
|
|
353
|
+
border-top-color: currentColor;
|
|
354
|
+
border-radius: 50%;
|
|
355
|
+
animation: workbase-spin 0.8s linear infinite;
|
|
356
|
+
}
|
|
357
|
+
@keyframes workbase-spin { to { transform: rotate(360deg); } }
|
|
358
|
+
|
|
359
|
+
.workbase-empty-state {
|
|
360
|
+
display: grid;
|
|
361
|
+
min-height: 140px;
|
|
362
|
+
place-content: center;
|
|
363
|
+
justify-items: center;
|
|
364
|
+
gap: 6px;
|
|
365
|
+
padding: 32px 20px;
|
|
366
|
+
text-align: center;
|
|
367
|
+
}
|
|
368
|
+
.workbase-empty-icon {
|
|
369
|
+
display: inline-grid;
|
|
370
|
+
place-items: center;
|
|
371
|
+
width: 36px;
|
|
372
|
+
height: 36px;
|
|
373
|
+
margin-bottom: 4px;
|
|
374
|
+
border-radius: 10px;
|
|
375
|
+
background: color-mix(in srgb, var(--color-accent) 10%, var(--color-surface));
|
|
376
|
+
color: var(--color-accent);
|
|
377
|
+
}
|
|
378
|
+
.workbase-empty-title {
|
|
379
|
+
margin: 0;
|
|
380
|
+
color: var(--color-foreground);
|
|
381
|
+
font-size: var(--workbase-type-section);
|
|
382
|
+
font-weight: 600;
|
|
383
|
+
line-height: 1.4;
|
|
384
|
+
}
|
|
385
|
+
.workbase-empty-description {
|
|
386
|
+
margin: 0;
|
|
387
|
+
max-width: 56ch;
|
|
388
|
+
color: var(--color-muted);
|
|
389
|
+
font-size: var(--workbase-type-body);
|
|
390
|
+
line-height: 1.6;
|
|
391
|
+
}
|
|
392
|
+
.workbase-empty-action {
|
|
393
|
+
display: flex;
|
|
394
|
+
flex-wrap: wrap;
|
|
395
|
+
justify-content: center;
|
|
396
|
+
gap: 8px;
|
|
397
|
+
margin-top: 8px;
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
.workbase-error-boundary {
|
|
401
|
+
width: 100%;
|
|
402
|
+
min-height: 100%;
|
|
403
|
+
padding-block: 16px;
|
|
404
|
+
background: var(--color-surface-raised);
|
|
405
|
+
}
|
|
406
|
+
.workbase-error-retry {
|
|
407
|
+
display: inline-flex;
|
|
408
|
+
align-items: center;
|
|
409
|
+
justify-content: center;
|
|
410
|
+
min-height: 32px;
|
|
411
|
+
padding: 4px 12px;
|
|
412
|
+
border: 1px solid var(--color-border-strong);
|
|
413
|
+
border-radius: 6px;
|
|
414
|
+
background: var(--color-surface);
|
|
415
|
+
color: var(--color-foreground);
|
|
416
|
+
font: inherit;
|
|
417
|
+
font-size: var(--workbase-type-meta);
|
|
418
|
+
font-weight: 600;
|
|
419
|
+
cursor: pointer;
|
|
420
|
+
}
|
|
421
|
+
.workbase-error-retry:hover { background: var(--color-surface-muted); }
|
|
422
|
+
.workbase-error-retry:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 2px; }
|
|
301
423
|
}
|
|
302
424
|
|
|
303
425
|
@layer components {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eworkbase/sdk",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.5",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
"./markdown": {
|
|
@@ -17,7 +17,8 @@
|
|
|
17
17
|
},
|
|
18
18
|
"./ui": {
|
|
19
19
|
"types": "./dist/ui/index.d.ts",
|
|
20
|
-
"import": "./dist/ui/index.js"
|
|
20
|
+
"import": "./dist/ui/index.js",
|
|
21
|
+
"default": "./dist/ui/index.js"
|
|
21
22
|
},
|
|
22
23
|
"./ui/index.css": {
|
|
23
24
|
"types": "./dist/ui/index.css.d.ts",
|
|
@@ -31,6 +32,10 @@
|
|
|
31
32
|
"types": "./dist/ui/error-panel.d.ts",
|
|
32
33
|
"import": "./dist/ui/error-panel.js"
|
|
33
34
|
},
|
|
35
|
+
"./ui/components": {
|
|
36
|
+
"types": "./dist/ui/components.d.ts",
|
|
37
|
+
"import": "./dist/ui/components.js"
|
|
38
|
+
},
|
|
34
39
|
"./ui/theme": {
|
|
35
40
|
"types": "./dist/ui/theme.d.ts",
|
|
36
41
|
"import": "./dist/ui/theme.js"
|
|
@@ -50,11 +55,11 @@
|
|
|
50
55
|
"engines": {
|
|
51
56
|
"node": ">=22"
|
|
52
57
|
},
|
|
58
|
+
"sideEffects": [
|
|
59
|
+
"*.css"
|
|
60
|
+
],
|
|
53
61
|
"dependencies": {
|
|
54
62
|
"penpal": "^7.0.0",
|
|
55
|
-
"react-markdown": "^10.1.0",
|
|
56
|
-
"remark-gfm": "^4.0.1",
|
|
57
|
-
"vditor": "^4.0.1",
|
|
58
63
|
"zod": "^4.6.5"
|
|
59
64
|
},
|
|
60
65
|
"publishConfig": {
|
|
@@ -68,15 +73,30 @@
|
|
|
68
73
|
"@types/node": "^24.0.3",
|
|
69
74
|
"@types/react": "^19.2.17",
|
|
70
75
|
"react": "^19.2.7",
|
|
76
|
+
"react-markdown": "^10.1.0",
|
|
77
|
+
"remark-gfm": "^4.0.1",
|
|
71
78
|
"tsdown": "0.23.0",
|
|
72
|
-
"typescript": "^5.8.3"
|
|
79
|
+
"typescript": "^5.8.3",
|
|
80
|
+
"vditor": "^4.0.1"
|
|
73
81
|
},
|
|
74
82
|
"peerDependencies": {
|
|
75
|
-
"react": "^19.1.0"
|
|
83
|
+
"react": "^19.1.0",
|
|
84
|
+
"react-markdown": "^10.1.0",
|
|
85
|
+
"remark-gfm": "^4.0.1",
|
|
86
|
+
"vditor": "^4.0.1"
|
|
76
87
|
},
|
|
77
88
|
"peerDependenciesMeta": {
|
|
78
89
|
"react": {
|
|
79
90
|
"optional": true
|
|
91
|
+
},
|
|
92
|
+
"react-markdown": {
|
|
93
|
+
"optional": true
|
|
94
|
+
},
|
|
95
|
+
"remark-gfm": {
|
|
96
|
+
"optional": true
|
|
97
|
+
},
|
|
98
|
+
"vditor": {
|
|
99
|
+
"optional": true
|
|
80
100
|
}
|
|
81
101
|
},
|
|
82
102
|
"scripts": {
|