@eworkbase/sdk 0.3.6 → 0.4.1

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.
@@ -1,5 +1,5 @@
1
+ import "vditor";
1
2
  //#region src/ui/MarkdownEditor.dto.d.ts
2
- /** Shared Markdown field contracts; no host transport or plugin business types. */
3
3
  interface MarkdownCompletion {
4
4
  readonly value: string;
5
5
  readonly description?: string;
@@ -8,6 +8,7 @@ interface MarkdownEditorProps {
8
8
  readonly value: string;
9
9
  readonly onChange: (value: string) => void;
10
10
  readonly label: string;
11
+ readonly sourcePath?: string;
11
12
  readonly name?: string;
12
13
  readonly placeholder?: string;
13
14
  readonly isReadOnly?: boolean;
@@ -19,5 +20,7 @@ interface MarkdownEditorProps {
19
20
  //#endregion
20
21
  //#region src/ui/MarkdownEditor.d.ts
21
22
  export declare const MarkdownEditor: import("react").NamedExoticComponent<MarkdownEditorProps>;
23
+ /** Reuses the bundled offline renderer for editors and linked document previews. */
24
+ export declare function renderMarkdownPreview(content: string): Promise<string>;
22
25
  //#endregion
23
26
  export type { MarkdownCompletion, MarkdownEditorProps };
@@ -5,6 +5,11 @@ import { jsx, jsxs } from "react/jsx-runtime";
5
5
  const ASSET_DIRECTORY = "./markdown-editor-assets/";
6
6
  const MINIMUM_EDITOR_HEIGHT = 360;
7
7
  const MAXIMUM_HINTS = 12;
8
+ const LUTE_SKIP_CHILDREN = 1;
9
+ const PREVIEW_RENDERERS = {
10
+ renderHTMLBlock: skipRawHtml,
11
+ renderInlineHTML: skipRawHtml
12
+ };
8
13
  const TOOLBAR = [
9
14
  "bold",
10
15
  "list",
@@ -43,7 +48,7 @@ const LOCAL_SCRIPTS = [
43
48
  id: "vditorLuteScript"
44
49
  }
45
50
  ];
46
- const MarkdownEditor = memo(function MarkdownEditor({ value, onChange, label, name, placeholder = "输入 Markdown…", isReadOnly = false, isDisabled = false, required, maxLength, completions = [] }) {
51
+ const MarkdownEditor = memo(function MarkdownEditor({ value, onChange, label, name, placeholder = "输入 Markdown…", isReadOnly = false, isDisabled = false, required, maxLength, completions = [], sourcePath }) {
47
52
  const container = useRef(null);
48
53
  const formValue = useRef(null);
49
54
  const editor = useRef(null);
@@ -69,6 +74,22 @@ const MarkdownEditor = memo(function MarkdownEditor({ value, onChange, label, na
69
74
  isDisabled,
70
75
  completions
71
76
  };
77
+ const handleOpenLink = useCallback((element) => {
78
+ const href = element.getAttribute("href") ?? element.textContent ?? "";
79
+ if (!!element.dispatchEvent(new CustomEvent("workbase-markdown-link", {
80
+ bubbles: true,
81
+ cancelable: true,
82
+ detail: href
83
+ }))) setValidationError("当前视图无法打开此链接。");
84
+ }, []);
85
+ const handleLinkClick = useCallback((event) => {
86
+ if (event.button !== 0 && event.button !== 1) return;
87
+ const link = event.target.closest?.("a[href]");
88
+ if (!link) return;
89
+ event.preventDefault();
90
+ event.stopPropagation();
91
+ handleOpenLink(link);
92
+ }, [handleOpenLink]);
72
93
  useEffect(() => {
73
94
  const element = container.current;
74
95
  let stopped = false;
@@ -85,8 +106,7 @@ const MarkdownEditor = memo(function MarkdownEditor({ value, onChange, label, na
85
106
  setIsReady(false);
86
107
  setError(null);
87
108
  try {
88
- await Promise.all(LOCAL_SCRIPTS.map(loadLocalScript));
89
- const { default: Editor } = await import("vditor");
109
+ const Editor = await loadMarkdownLibrary();
90
110
  if (stopped) return;
91
111
  instance = new Editor(element, {
92
112
  value: latest.current.value,
@@ -103,7 +123,10 @@ const MarkdownEditor = memo(function MarkdownEditor({ value, onChange, label, na
103
123
  max: maxLength,
104
124
  type: "markdown"
105
125
  },
106
- link: { isOpen: false },
126
+ link: {
127
+ isOpen: false,
128
+ click: handleOpenLink
129
+ },
107
130
  image: { isPreview: false },
108
131
  preview: {
109
132
  actions: [],
@@ -167,6 +190,7 @@ const MarkdownEditor = memo(function MarkdownEditor({ value, onChange, label, na
167
190
  };
168
191
  }, [
169
192
  attempt,
193
+ handleOpenLink,
170
194
  labelId,
171
195
  maxLength,
172
196
  placeholder
@@ -201,36 +225,19 @@ const MarkdownEditor = memo(function MarkdownEditor({ value, onChange, label, na
201
225
  editor.current.focus();
202
226
  }
203
227
  }, []);
204
- const handleInsert = useCallback((event) => {
205
- const token = event.currentTarget.value;
206
- if (token && editor.current) {
207
- editor.current.insertValue(token + " ");
208
- editor.current.focus();
209
- }
210
- }, []);
211
228
  return /* @__PURE__ */ jsxs("div", {
212
229
  className: "workbase-markdown-editor",
213
230
  "data-readonly": isReadOnly,
214
231
  "data-disabled": isDisabled,
232
+ "data-markdown-source": sourcePath ?? "",
233
+ onClickCapture: handleLinkClick,
234
+ onAuxClickCapture: handleLinkClick,
215
235
  children: [
216
236
  /* @__PURE__ */ jsx("span", {
217
237
  className: "markdown-field-label",
218
238
  id: labelId,
219
239
  children: label
220
240
  }),
221
- completions.length && !isReadOnly ? /* @__PURE__ */ jsxs("select", {
222
- "aria-label": "插入资源引用",
223
- value: "",
224
- onChange: handleInsert,
225
- disabled: !isReady || isDisabled,
226
- children: [/* @__PURE__ */ jsx("option", {
227
- value: "",
228
- children: "插入资源引用…"
229
- }), completions.map(({ value: token, description }) => /* @__PURE__ */ jsxs("option", {
230
- value: token,
231
- children: [token, description ? " · " + description : ""]
232
- }, token))]
233
- }) : null,
234
241
  error ? /* @__PURE__ */ jsxs("p", {
235
242
  role: "alert",
236
243
  className: "markdown-editor-error",
@@ -275,6 +282,27 @@ const MarkdownEditor = memo(function MarkdownEditor({ value, onChange, label, na
275
282
  ]
276
283
  });
277
284
  });
285
+ /** Reuses the bundled offline renderer for editors and linked document previews. */
286
+ async function renderMarkdownPreview(content) {
287
+ return plainCodePreview(await (await loadMarkdownLibrary()).md2html(content, {
288
+ mode: "light",
289
+ renderers: PREVIEW_RENDERERS,
290
+ cdn: new URL(ASSET_DIRECTORY, document.baseURI).href,
291
+ markdown: {
292
+ sanitize: true,
293
+ autoSpace: false,
294
+ fixTermTypo: false,
295
+ codeBlockPreview: false,
296
+ mathBlockPreview: false,
297
+ inlineMath: false
298
+ }
299
+ }));
300
+ }
301
+ async function loadMarkdownLibrary() {
302
+ await Promise.all(LOCAL_SCRIPTS.map(loadLocalScript));
303
+ const { default: Editor } = await import("vditor");
304
+ return Editor;
305
+ }
278
306
  async function loadLocalScript({ file, id }) {
279
307
  const previous = document.getElementById(id);
280
308
  if (previous?.dataset.loaded === "true") return;
@@ -326,5 +354,8 @@ function escapeText(text) {
326
354
  function plainCodePreview(html) {
327
355
  return html.replace(/class="language-[^"]*"/g, "class=\"language-text\"");
328
356
  }
357
+ function skipRawHtml() {
358
+ return ["", LUTE_SKIP_CHILDREN];
359
+ }
329
360
  //#endregion
330
- export { MarkdownEditor };
361
+ export { MarkdownEditor, renderMarkdownPreview };
@@ -0,0 +1,12 @@
1
+ import { D as WorkbasePluginUi } from "../types-C8byxPji.js";
2
+ import { ReactNode } from "react";
3
+ //#region src/ui/MarkdownLinks.dto.d.ts
4
+ interface MarkdownLinksProps {
5
+ readonly host: WorkbasePluginUi | null;
6
+ readonly contextKey: string;
7
+ readonly children: ReactNode;
8
+ }
9
+ //#endregion
10
+ //#region src/ui/MarkdownLinks.d.ts
11
+ export declare const MarkdownLinks: import("react").NamedExoticComponent<MarkdownLinksProps>;
12
+ //#endregion
@@ -0,0 +1,246 @@
1
+ import { t as parseMarkdownLink } from "../markdown-link-C-qw7xuN.js";
2
+ import { renderMarkdownPreview } from "./markdown-editor.js";
3
+ import { memo, useCallback, useEffect, useId, useRef, useState } from "react";
4
+ import { jsx, jsxs } from "react/jsx-runtime";
5
+ //#region src/ui/MarkdownLinks.tsx
6
+ /** Keeps Markdown navigation inside its document context while preserving mounted editors. */
7
+ const MAXIMUM_CACHED_DOCUMENTS = 8;
8
+ const DOCUMENT_SOURCE_SELECTOR = "[data-markdown-source]";
9
+ const HEADING_SELECTOR = "h1,h2,h3,h4,h5,h6";
10
+ const INACTIVE_PREVIEW_ELEMENTS = "img,iframe,object,embed,audio,video,source,script,style,link,meta,base,form,button";
11
+ const MarkdownLinks = memo(function MarkdownLinks(props) {
12
+ return /* @__PURE__ */ jsx(MarkdownLinkBoundary, { ...props }, props.contextKey);
13
+ });
14
+ function MarkdownLinkBoundary({ host, children }) {
15
+ const container = useRef(null);
16
+ const previewPanel = useRef(null);
17
+ const returnFocus = useRef(null);
18
+ const cache = useRef(/* @__PURE__ */ new Map());
19
+ const pending = useRef(/* @__PURE__ */ new Map());
20
+ const version = useRef(0);
21
+ const [preview, setPreview] = useState(null);
22
+ const [request, setRequest] = useState(null);
23
+ const [error, setError] = useState("");
24
+ const [isLoading, setLoading] = useState(false);
25
+ const [isOpeningWebsite, setOpeningWebsite] = useState(false);
26
+ const labelId = useId();
27
+ const open = useCallback(async (options, origin) => {
28
+ const currentVersion = ++version.current;
29
+ setError("");
30
+ setRequest(options);
31
+ try {
32
+ const link = parseMarkdownLink(options.href);
33
+ if (link.kind === "anchor") {
34
+ scrollToAnchor(origin?.closest(DOCUMENT_SOURCE_SELECTOR) ?? container.current, link.fragment);
35
+ return;
36
+ }
37
+ if (!host) throw new Error("当前工作区尚未就绪,请稍后重试。");
38
+ const key = JSON.stringify([options.sourcePath ?? "", options.href]);
39
+ const isDocument = link.kind === "document";
40
+ if (origin instanceof HTMLElement && !origin.closest(".markdown-document-preview")) returnFocus.current = origin.closest("a[href],[contenteditable=\"true\"],textarea,button,[tabindex]") ?? origin;
41
+ if (isDocument) {
42
+ previewPanel.current?.focus();
43
+ previewPanel.current?.scrollIntoView({ block: "nearest" });
44
+ }
45
+ setLoading(isDocument);
46
+ setOpeningWebsite(!isDocument);
47
+ const cached = cache.current.get(key);
48
+ if (cached) setPreview(cached);
49
+ let response = pending.current.get(key);
50
+ if (!response) {
51
+ response = host.view.call("openMarkdownLink", options);
52
+ pending.current.set(key, response);
53
+ }
54
+ let document;
55
+ try {
56
+ document = await response;
57
+ } finally {
58
+ if (pending.current.get(key) === response) pending.current.delete(key);
59
+ }
60
+ if (version.current !== currentVersion) return;
61
+ if (!document) return;
62
+ setError("");
63
+ cache.current.set(key, document);
64
+ if (cache.current.size > MAXIMUM_CACHED_DOCUMENTS) cache.current.delete(cache.current.keys().next().value);
65
+ setPreview(document);
66
+ } catch (failure) {
67
+ if (version.current === currentVersion) setError(readableError(failure));
68
+ } finally {
69
+ if (version.current === currentVersion) {
70
+ setLoading(false);
71
+ setOpeningWebsite(false);
72
+ }
73
+ }
74
+ }, [host]);
75
+ const handleClose = useCallback(() => {
76
+ version.current += 1;
77
+ setPreview(null);
78
+ setRequest(null);
79
+ setLoading(false);
80
+ setOpeningWebsite(false);
81
+ setError("");
82
+ if (returnFocus.current?.isConnected) returnFocus.current.focus();
83
+ }, []);
84
+ const handleRetry = useCallback(() => {
85
+ if (request) open(request);
86
+ }, [open, request]);
87
+ const handlePreviewError = useCallback((message) => setError(message), []);
88
+ useEffect(() => {
89
+ const element = container.current;
90
+ if (!element) return;
91
+ const handleClick = (event) => {
92
+ if (event.button !== 0 && event.button !== 1) return;
93
+ const link = event.target.closest?.("a[href]");
94
+ if (!link) return;
95
+ event.preventDefault();
96
+ event.stopPropagation();
97
+ const sourcePath = link.closest(DOCUMENT_SOURCE_SELECTOR)?.getAttribute("data-markdown-source") || void 0;
98
+ open({
99
+ href: link.getAttribute("href") ?? "",
100
+ sourcePath
101
+ }, link);
102
+ };
103
+ const handleEditorLink = (event) => {
104
+ const { detail } = event;
105
+ event.preventDefault();
106
+ event.stopPropagation();
107
+ if (typeof detail !== "string") return;
108
+ const target = event.target;
109
+ const sourcePath = target.closest(DOCUMENT_SOURCE_SELECTOR)?.getAttribute("data-markdown-source") || void 0;
110
+ open({
111
+ href: detail,
112
+ sourcePath
113
+ }, target);
114
+ };
115
+ element.addEventListener("click", handleClick, true);
116
+ element.addEventListener("auxclick", handleClick, true);
117
+ element.addEventListener("workbase-markdown-link", handleEditorLink);
118
+ return () => {
119
+ version.current += 1;
120
+ element.removeEventListener("click", handleClick, true);
121
+ element.removeEventListener("auxclick", handleClick, true);
122
+ element.removeEventListener("workbase-markdown-link", handleEditorLink);
123
+ };
124
+ }, [open]);
125
+ const hasPreview = Boolean(preview || isLoading);
126
+ useEffect(() => {
127
+ if (!hasPreview) return;
128
+ previewPanel.current?.focus();
129
+ previewPanel.current?.scrollIntoView({ block: "nearest" });
130
+ }, [hasPreview]);
131
+ return /* @__PURE__ */ jsxs("div", {
132
+ ref: container,
133
+ className: "workbase-markdown-links",
134
+ children: [
135
+ error ? /* @__PURE__ */ jsxs("p", {
136
+ role: "alert",
137
+ className: "markdown-link-error",
138
+ children: [error, request ? /* @__PURE__ */ jsx("button", {
139
+ type: "button",
140
+ onClick: handleRetry,
141
+ children: "重试打开"
142
+ }) : null]
143
+ }) : null,
144
+ isOpeningWebsite ? /* @__PURE__ */ jsx("p", {
145
+ role: "status",
146
+ children: "正在等待打开网页的确认…"
147
+ }) : null,
148
+ hasPreview ? /* @__PURE__ */ jsxs("section", {
149
+ ref: previewPanel,
150
+ tabIndex: -1,
151
+ className: "markdown-document-preview",
152
+ "aria-labelledby": labelId,
153
+ children: [
154
+ /* @__PURE__ */ jsxs("div", {
155
+ className: "markdown-document-heading",
156
+ children: [/* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("h2", {
157
+ id: labelId,
158
+ children: "文档预览"
159
+ }), /* @__PURE__ */ jsx("p", { children: preview?.path ?? request?.href })] }), /* @__PURE__ */ jsx("button", {
160
+ type: "button",
161
+ onClick: handleClose,
162
+ children: "关闭预览"
163
+ })]
164
+ }),
165
+ isLoading ? /* @__PURE__ */ jsx("p", {
166
+ role: "status",
167
+ children: preview ? "正在读取最新文档,当前显示上次内容…" : "正在读取文档…"
168
+ }) : null,
169
+ preview ? /* @__PURE__ */ jsx(MarkdownPreview, {
170
+ document: preview,
171
+ onError: handlePreviewError
172
+ }, preview.path) : null
173
+ ]
174
+ }) : null,
175
+ children
176
+ ]
177
+ });
178
+ }
179
+ const MarkdownPreview = memo(function MarkdownPreview({ document: markdownDocument, onError }) {
180
+ const container = useRef(null);
181
+ const [isRendering, setRendering] = useState(true);
182
+ useEffect(() => {
183
+ let stopped = false;
184
+ const render = async () => {
185
+ setRendering(true);
186
+ try {
187
+ const html = await renderMarkdownPreview(markdownDocument.content);
188
+ if (stopped || !container.current) return;
189
+ const template = document.createElement("template");
190
+ template.innerHTML = html;
191
+ template.content.querySelectorAll(INACTIVE_PREVIEW_ELEMENTS).forEach((element) => element.remove());
192
+ template.content.querySelectorAll("input[type=\"checkbox\"]").forEach((checkbox) => {
193
+ checkbox.disabled = true;
194
+ });
195
+ container.current.replaceChildren(template.content);
196
+ if (markdownDocument.fragment) scrollToAnchor(container.current, markdownDocument.fragment);
197
+ } catch (failure) {
198
+ if (!stopped) onError(readableError(failure));
199
+ } finally {
200
+ if (!stopped) setRendering(false);
201
+ }
202
+ };
203
+ render();
204
+ return () => {
205
+ stopped = true;
206
+ };
207
+ }, [
208
+ markdownDocument.content,
209
+ markdownDocument.fragment,
210
+ markdownDocument.revision,
211
+ onError
212
+ ]);
213
+ return /* @__PURE__ */ jsxs("div", {
214
+ "data-markdown-source": markdownDocument.path,
215
+ children: [isRendering ? /* @__PURE__ */ jsx("p", {
216
+ role: "status",
217
+ children: "正在排版文档…"
218
+ }) : null, /* @__PURE__ */ jsx("div", {
219
+ ref: container,
220
+ className: "markdown-document-body vditor-reset"
221
+ })]
222
+ });
223
+ });
224
+ function scrollToAnchor(root, fragment) {
225
+ if (!root) return;
226
+ if (!fragment) {
227
+ root.scrollIntoView({ block: "start" });
228
+ return;
229
+ }
230
+ const identified = Array.from(root.querySelectorAll("[id]")).find(({ id }) => id === fragment);
231
+ const counts = /* @__PURE__ */ new Map();
232
+ const heading = Array.from(root.querySelectorAll(HEADING_SELECTOR)).find((element) => {
233
+ const slug = (element.textContent ?? "").trim().toLowerCase().replace(/[^\p{L}\p{N}_\s-]/gu, "").replace(/\s/g, "-");
234
+ const count = counts.get(slug) ?? 0;
235
+ counts.set(slug, count + 1);
236
+ return (count ? slug + "-" + count : slug) === fragment;
237
+ });
238
+ const target = identified ?? heading;
239
+ if (!target) throw new Error("文档中未找到标题:" + fragment);
240
+ target.scrollIntoView({ block: "start" });
241
+ }
242
+ function readableError(failure) {
243
+ return failure instanceof Error ? failure.message : "链接打开失败,请重试。";
244
+ }
245
+ //#endregion
246
+ export { MarkdownLinks };
@@ -20,4 +20,6 @@ export declare function configurationSavedMessage(publication: {
20
20
  export declare function formatActionOutput(title: string, result: unknown, logs: unknown): PluginActionOutput;
21
21
  export declare function formatActionError(title: string, error: unknown): PluginActionOutput;
22
22
  export declare function readableError(error: unknown, fallback: string): string;
23
+ /** Keeps the actual cause visible while leaving stack frames in technical details. */
24
+ export declare function errorSummary(message: string): string;
23
25
  //#endregion
package/dist/ui/model.js CHANGED
@@ -29,6 +29,10 @@ function formatActionError(title, error) {
29
29
  function readableError(error, fallback) {
30
30
  return error instanceof Error && error.message.trim().length > 0 ? error.message : fallback;
31
31
  }
32
+ /** Keeps the actual cause visible while leaving stack frames in technical details. */
33
+ function errorSummary(message) {
34
+ return message.split(/\n\s+at\s/, 1)[0].trim();
35
+ }
32
36
  function formatLogEntries(value) {
33
37
  if (!Array.isArray(value)) return "";
34
38
  return value.filter(isRecord).map((entry) => {
@@ -46,4 +50,4 @@ function isRecord(value) {
46
50
  return value !== null && typeof value === "object" && !Array.isArray(value);
47
51
  }
48
52
  //#endregion
49
- export { ConfigurationMode, TEAM_CONFIGURATION_NOTICE, configurationSavedMessage, formatActionError, formatActionOutput, readableError };
53
+ export { ConfigurationMode, TEAM_CONFIGURATION_NOTICE, configurationSavedMessage, errorSummary, formatActionError, formatActionOutput, readableError };
package/dist/ui/theme.css CHANGED
@@ -188,6 +188,32 @@
188
188
 
189
189
  .mantine-Alert-root { padding: 12px; border: 1px solid color-mix(in srgb, currentColor 20%, transparent); }
190
190
  .mantine-Alert-message { color: inherit; font-size: 14px; line-height: 1.5; }
191
+ .workbase-plugin-error {
192
+ min-width: 0;
193
+ max-height: 100%;
194
+ flex-shrink: 0;
195
+ overflow-y: auto;
196
+ padding: 16px 20px;
197
+ border: 1px solid color-mix(in srgb, var(--color-danger) 24%, var(--color-border));
198
+ border-radius: 8px;
199
+ color: var(--color-foreground);
200
+ background: color-mix(in srgb, var(--color-danger) 5%, var(--color-surface));
201
+ text-align: left;
202
+ overflow-wrap: anywhere;
203
+ scrollbar-color: var(--color-border-strong) transparent;
204
+ scrollbar-width: thin;
205
+ }
206
+ .workbase-plugin-error:focus-visible { outline: 2px solid var(--color-accent); outline-offset: -2px; }
207
+ .workbase-plugin-error .workbase-error-title { margin: 0 0 8px; color: var(--color-danger); font-size: 14px; font-weight: 600; line-height: 1.5; }
208
+ .workbase-plugin-error .workbase-error-cause { margin: 0; color: var(--color-foreground); font-size: 14px; font-weight: 500; line-height: 1.65; white-space: pre-wrap; }
209
+ .workbase-plugin-error .workbase-error-context { margin: 8px 0 0; color: var(--color-foreground); font-size: 12px; font-weight: 400; line-height: 1.65; }
210
+ .workbase-error-context strong { margin-right: 8px; font-weight: 600; }
211
+ .workbase-error-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
212
+ .workbase-error-details { margin-top: 12px; color: var(--color-foreground); font-size: 12px; font-weight: 400; }
213
+ .workbase-error-details summary { width: fit-content; cursor: pointer; text-underline-offset: 3px; }
214
+ .workbase-error-details summary:hover { text-decoration: underline; }
215
+ .workbase-error-details summary:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 3px; border-radius: 4px; }
216
+ .workbase-error-details pre { max-width: 100%; max-height: 240px; margin: 8px 0 0; padding: 12px; overflow: auto; border-radius: 4px; color: var(--color-foreground); background: var(--color-surface); font-size: 12px; line-height: 1.65; white-space: pre-wrap; overflow-wrap: anywhere; scrollbar-color: var(--color-border-strong) transparent; scrollbar-width: thin; }
191
217
  .mantine-Notification-root { border: 1px solid var(--color-border); }
192
218
  .mantine-Notification-title { color: var(--color-brand-deep); font-weight: 600; }
193
219
  .mantine-Notification-description { color: var(--color-muted); }
@@ -200,3 +226,83 @@
200
226
  outline-offset: 2px;
201
227
  }
202
228
  }
229
+
230
+ @layer components {
231
+ .workbase-execution-log { min-width: 0; font-size: 14px; line-height: 1.7; }
232
+ .workbase-execution-log[data-display="full"] { max-width: calc(75ch + 100px); }
233
+ .workbase-log-entries { list-style: none; margin: 0; padding: 0; }
234
+ .workbase-log-entry { position: relative; display: grid; grid-template-columns: 72px minmax(0, 1fr); gap: 28px; padding: 0 0 20px; min-width: 0; scroll-margin-top: 24px; }
235
+ .workbase-log-entry:last-child { padding-bottom: 0; }
236
+ .workbase-log-entry::before { content: ""; position: absolute; left: 84px; top: 9px; width: 7px; height: 7px; border: 1px solid var(--color-border-strong); border-radius: 50%; background: var(--color-surface); }
237
+ .workbase-log-entry:not(:last-child)::after { content: ""; position: absolute; left: 87px; top: 20px; bottom: 2px; width: 1px; background: var(--color-border); }
238
+ .workbase-log-entry[data-status="failed"]::before { border-color: var(--color-danger); background: var(--color-danger); }
239
+ .workbase-log-entry[data-status="pending"]::before { border-color: var(--color-warning); background: var(--color-brand-weak); }
240
+ .workbase-log-entry:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 4px; }
241
+ .workbase-log-time { grid-column: 1; grid-row: 1; padding-top: 2px; color: var(--color-muted); font-size: 12px; font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
242
+ .workbase-log-body { position: relative; grid-column: 2; grid-row: 1; min-width: 0; }
243
+ .workbase-log-heading { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; min-height: 24px; margin-bottom: 8px; }
244
+ .workbase-log-heading strong { flex: 1; min-width: 0; overflow-wrap: anywhere; font-size: 14px; font-weight: 600; }
245
+ .workbase-log-kind, .workbase-log-status, .workbase-log-note { color: var(--color-muted); font-size: 12px; }
246
+ .workbase-log-status { margin-left: auto; white-space: nowrap; }
247
+ .workbase-execution-log[data-display="full"] .workbase-log-heading strong { flex: 0 1 auto; }
248
+ .workbase-execution-log[data-display="full"] .workbase-log-status { margin-left: 0; }
249
+ .workbase-log-status[data-status="failed"], .workbase-log-error { color: var(--color-danger); }
250
+ .workbase-log-status[data-status="completed"] { color: var(--color-success); }
251
+ .workbase-log-status:is([data-status="needs_action"], [data-status="warning"]) { color: var(--color-warning); }
252
+ .workbase-log-status:is([data-status="pending"], [data-status="invalid"]) { color: var(--color-warning); }
253
+ .workbase-log-content { max-width: 75ch; overflow-wrap: anywhere; }
254
+ .workbase-log-content > :first-child { margin-top: 0; }
255
+ .workbase-log-content > :last-child { margin-bottom: 0; }
256
+ .workbase-log-content :is(h1, h2, h3, h4) { margin-block: 20px 8px; font-size: 1em; line-height: 1.5; }
257
+ .workbase-log-content :is(p, ul, ol, pre, blockquote, table) { margin-block: 8px 12px; }
258
+ .workbase-log-content :is(ul, ol) { padding-left: 22px; }
259
+ .workbase-log-content ul { list-style: disc; }
260
+ .workbase-log-content ol { list-style: decimal; }
261
+ .workbase-log-content a { color: var(--color-brand); text-decoration: underline; text-underline-offset: 3px; }
262
+ .workbase-log-content pre, .workbase-log-details pre, .workbase-log-raw { max-height: 360px; overflow: auto; max-width: 100%; padding: 12px; background: var(--color-surface-muted); white-space: pre-wrap; overflow-wrap: anywhere; font-size: 12px; scrollbar-color: var(--color-border-strong) transparent; scrollbar-width: thin; }
263
+ .workbase-log-content table { display: block; overflow-x: auto; }
264
+ .workbase-log-content :is(th, td) { padding: 6px 10px; border-bottom: 1px solid var(--color-border); text-align: left; }
265
+ .workbase-log-details { margin-top: 10px; }
266
+ .workbase-log-details summary { width: fit-content; cursor: pointer; color: var(--color-muted); font-size: 12px; }
267
+ .workbase-log-operation > summary { min-height: 28px; cursor: pointer; border-radius: 4px; }
268
+ .workbase-log-operation .workbase-log-heading { display: inline-flex; width: calc(100% - 1.25em); margin: 0; vertical-align: middle; }
269
+ .workbase-log-operation[open] > summary { margin-bottom: 12px; }
270
+ .workbase-log-operation summary:hover { color: var(--color-brand); }
271
+ .workbase-execution-log summary:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 4px; }
272
+ .workbase-execution-log ::selection { background: var(--color-brand-weak); color: var(--color-foreground); }
273
+ .workbase-log-anchor { position: absolute; top: 0; }
274
+ .workbase-log-calls { margin: 12px 0; padding: 0; list-style: none; }
275
+ .workbase-log-calls > li { display: grid; grid-template-columns: minmax(0, 1fr) max-content max-content; align-items: center; gap: 4px 16px; padding-block: 8px; font-size: 13px; }
276
+ .workbase-log-calls > li + li { border-top: 1px solid var(--color-border); }
277
+ .workbase-log-calls > li > span:first-child { min-width: 0; overflow-wrap: anywhere; }
278
+ .workbase-log-calls .workbase-log-note { white-space: nowrap; }
279
+ .workbase-log-link, .workbase-log-copy button { border: 0; min-height: 32px; padding: 4px 0; background: transparent; color: var(--color-brand); font: inherit; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
280
+ .workbase-log-calls .workbase-log-link { justify-self: end; white-space: nowrap; }
281
+ .workbase-log-copy { display: flex; align-items: center; gap: 12px; color: var(--color-muted); font-size: 12px; }
282
+ .workbase-log-follow { display: flex; justify-content: center; padding-top: 8px; }
283
+ .workbase-log-latest { min-height: 28px; border: 1px solid var(--color-border-strong); border-radius: 6px; padding: 3px 10px; background: var(--color-surface); color: var(--color-foreground); font: inherit; font-size: 12px; cursor: pointer; }
284
+ .workbase-log-latest[data-following="true"] { visibility: hidden; }
285
+ .workbase-execution-log button:focus-visible, .workbase-log-viewport:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 3px; }
286
+ .workbase-execution-log[data-display="compact"] .workbase-log-viewport { max-height: 280px; overflow: auto; padding: 2px 10px 2px 2px; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: var(--color-border-strong) transparent; }
287
+ .workbase-execution-log[data-display="compact"] .workbase-log-entry { grid-template-columns: minmax(0, 1fr) auto; gap: 12px; padding: 0 0 18px 22px; }
288
+ .workbase-execution-log[data-display="compact"] .workbase-log-entry::before { left: 2px; top: 7px; }
289
+ .workbase-execution-log[data-display="compact"] .workbase-log-entry::after { left: 5px; top: 18px; }
290
+ .workbase-execution-log[data-display="compact"] .workbase-log-entry[data-status="completed"]::before { background: var(--color-success); border-color: var(--color-success); }
291
+ .workbase-execution-log[data-display="compact"] .workbase-log-time { grid-column: 2; grid-row: 1; padding: 0; line-height: 20px; }
292
+ .workbase-execution-log[data-display="compact"] .workbase-log-body { grid-column: 1; grid-row: 1; padding: 0; }
293
+ .workbase-execution-log[data-display="compact"] .workbase-log-heading { margin: 0; min-height: 20px; }
294
+ .workbase-execution-log[data-display="compact"] .workbase-log-heading strong { display: -webkit-box; overflow: hidden; -webkit-box-orient: vertical; -webkit-line-clamp: 2; font-size: 13px; line-height: 20px; font-weight: 500; }
295
+ .workbase-execution-log[data-display="compact"] .workbase-log-status { flex-shrink: 0; font-size: 12px; white-space: nowrap; }
296
+ .workbase-execution-log[data-display="compact"] .workbase-log-status:not([data-status="failed"], [data-status="needs_action"], [data-status="warning"], [data-status="interrupted"]) { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
297
+ @media (max-width: 600px) {
298
+ .workbase-execution-log[data-display="full"] .workbase-log-entry { grid-template-columns: minmax(0, 1fr); gap: 4px; padding-left: 20px; }
299
+ .workbase-execution-log[data-display="full"] .workbase-log-time { grid-column: 1; grid-row: 1; text-align: left; }
300
+ .workbase-execution-log[data-display="full"] .workbase-log-body { grid-column: 1; grid-row: 2; }
301
+ .workbase-execution-log[data-display="full"] .workbase-log-entry::before { left: 0; top: 9px; }
302
+ .workbase-execution-log[data-display="full"] .workbase-log-entry:not(:last-child)::after { left: 3px; }
303
+ .workbase-log-calls > li { grid-template-columns: minmax(0, 1fr) auto; }
304
+ .workbase-log-calls > li > span:first-child { grid-column: 1 / -1; }
305
+ .workbase-log-calls .workbase-log-link { grid-column: 2; }
306
+ .workbase-log-kind { margin-left: 0; }
307
+ }
308
+ }
package/package.json CHANGED
@@ -1,8 +1,16 @@
1
1
  {
2
2
  "name": "@eworkbase/sdk",
3
- "version": "0.3.6",
3
+ "version": "0.4.1",
4
4
  "type": "module",
5
5
  "exports": {
6
+ "./markdown": {
7
+ "types": "./dist/markdown.d.ts",
8
+ "import": "./dist/markdown.js"
9
+ },
10
+ "./ui/markdown-links": {
11
+ "types": "./dist/ui/markdown-links.d.ts",
12
+ "import": "./dist/ui/markdown-links.js"
13
+ },
6
14
  ".": {
7
15
  "types": "./dist/index.d.ts",
8
16
  "import": "./dist/index.js"
@@ -19,6 +27,10 @@
19
27
  "types": "./dist/ui/model.d.ts",
20
28
  "import": "./dist/ui/model.js"
21
29
  },
30
+ "./ui/error-panel": {
31
+ "types": "./dist/ui/error-panel.d.ts",
32
+ "import": "./dist/ui/error-panel.js"
33
+ },
22
34
  "./ui/theme": {
23
35
  "types": "./dist/ui/theme.d.ts",
24
36
  "import": "./dist/ui/theme.js"
@@ -29,15 +41,21 @@
29
41
  "import": "./dist/ui/markdown-editor.js"
30
42
  },
31
43
  "./ui/markdown-editor.css": "./dist/style.css",
32
- "./ui/markdown-editor-assets": "./dist/ui/markdown-editor-assets/lute.min.js"
44
+ "./ui/markdown-editor-assets": "./dist/ui/markdown-editor-assets/lute.min.js",
45
+ "./ui/execution-log": {
46
+ "types": "./dist/ui/execution-log.d.ts",
47
+ "import": "./dist/ui/execution-log.js"
48
+ }
33
49
  },
34
50
  "engines": {
35
51
  "node": ">=22"
36
52
  },
37
53
  "dependencies": {
38
54
  "penpal": "^7.0.0",
39
- "zod": "^4.6.5",
40
- "vditor": "^4.0.1"
55
+ "react-markdown": "^10.1.0",
56
+ "remark-gfm": "^4.0.1",
57
+ "vditor": "^4.0.1",
58
+ "zod": "^4.6.5"
41
59
  },
42
60
  "publishConfig": {
43
61
  "access": "public"