@bpmnkit/plugins 0.0.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/README.md +153 -0
- package/dist/ai-bridge/css.d.ts +2 -0
- package/dist/ai-bridge/css.js +366 -0
- package/dist/ai-bridge/index.d.ts +44 -0
- package/dist/ai-bridge/index.js +132 -0
- package/dist/ai-bridge/panel.d.ts +27 -0
- package/dist/ai-bridge/panel.js +715 -0
- package/dist/ascii-view/css.d.ts +4 -0
- package/dist/ascii-view/css.js +83 -0
- package/dist/ascii-view/index.d.ts +25 -0
- package/dist/ascii-view/index.js +92 -0
- package/dist/command-palette/css.d.ts +4 -0
- package/dist/command-palette/css.js +157 -0
- package/dist/command-palette/index.d.ts +53 -0
- package/dist/command-palette/index.js +378 -0
- package/dist/command-palette-editor/index.d.ts +35 -0
- package/dist/command-palette-editor/index.js +60 -0
- package/dist/config-panel/css.d.ts +4 -0
- package/dist/config-panel/css.js +719 -0
- package/dist/config-panel/index.d.ts +36 -0
- package/dist/config-panel/index.js +73 -0
- package/dist/config-panel/renderer.d.ts +127 -0
- package/dist/config-panel/renderer.js +1162 -0
- package/dist/config-panel/types.d.ts +118 -0
- package/dist/config-panel/types.js +2 -0
- package/dist/config-panel-bpmn/index.d.ts +58 -0
- package/dist/config-panel-bpmn/index.js +1320 -0
- package/dist/config-panel-bpmn/template-engine.d.ts +17 -0
- package/dist/config-panel-bpmn/template-engine.js +307 -0
- package/dist/config-panel-bpmn/template-to-service-task.d.ts +30 -0
- package/dist/config-panel-bpmn/template-to-service-task.js +92 -0
- package/dist/config-panel-bpmn/template-types.d.ts +126 -0
- package/dist/config-panel-bpmn/template-types.js +6 -0
- package/dist/config-panel-bpmn/templates/generated.d.ts +3 -0
- package/dist/config-panel-bpmn/templates/generated.js +57865 -0
- package/dist/config-panel-bpmn/util.d.ts +46 -0
- package/dist/config-panel-bpmn/util.js +195 -0
- package/dist/dmn-editor/css.d.ts +3 -0
- package/dist/dmn-editor/css.js +667 -0
- package/dist/dmn-editor/dmn-editor.d.ts +34 -0
- package/dist/dmn-editor/dmn-editor.js +646 -0
- package/dist/dmn-editor/drd-canvas.d.ts +85 -0
- package/dist/dmn-editor/drd-canvas.js +1087 -0
- package/dist/dmn-editor/index.d.ts +3 -0
- package/dist/dmn-editor/index.js +2 -0
- package/dist/dmn-viewer/css.d.ts +3 -0
- package/dist/dmn-viewer/css.js +151 -0
- package/dist/dmn-viewer/dmn-viewer.d.ts +30 -0
- package/dist/dmn-viewer/dmn-viewer.js +160 -0
- package/dist/dmn-viewer/feel.d.ts +3 -0
- package/dist/dmn-viewer/feel.js +2 -0
- package/dist/dmn-viewer/index.d.ts +14 -0
- package/dist/dmn-viewer/index.js +12 -0
- package/dist/element-docs/content.d.ts +20 -0
- package/dist/element-docs/content.js +1032 -0
- package/dist/element-docs/index.d.ts +7 -0
- package/dist/element-docs/index.js +643 -0
- package/dist/feel-playground/css.d.ts +4 -0
- package/dist/feel-playground/css.js +292 -0
- package/dist/feel-playground/index.d.ts +4 -0
- package/dist/feel-playground/index.js +3 -0
- package/dist/feel-playground/playground-plugin.d.ts +14 -0
- package/dist/feel-playground/playground-plugin.js +292 -0
- package/dist/form-editor/css.d.ts +3 -0
- package/dist/form-editor/css.js +703 -0
- package/dist/form-editor/form-editor.d.ts +48 -0
- package/dist/form-editor/form-editor.js +1039 -0
- package/dist/form-editor/index.d.ts +3 -0
- package/dist/form-editor/index.js +2 -0
- package/dist/form-viewer/css.d.ts +3 -0
- package/dist/form-viewer/css.js +303 -0
- package/dist/form-viewer/form-viewer.d.ts +29 -0
- package/dist/form-viewer/form-viewer.js +376 -0
- package/dist/form-viewer/index.d.ts +12 -0
- package/dist/form-viewer/index.js +11 -0
- package/dist/history/checkpoint.d.ts +10 -0
- package/dist/history/checkpoint.js +92 -0
- package/dist/history/css.d.ts +2 -0
- package/dist/history/css.js +130 -0
- package/dist/history/history-panel.d.ts +12 -0
- package/dist/history/history-panel.js +142 -0
- package/dist/history/index.d.ts +5 -0
- package/dist/history/index.js +3 -0
- package/dist/main-menu/css.d.ts +4 -0
- package/dist/main-menu/css.js +272 -0
- package/dist/main-menu/index.d.ts +59 -0
- package/dist/main-menu/index.js +285 -0
- package/dist/minimap/css.d.ts +10 -0
- package/dist/minimap/css.js +54 -0
- package/dist/minimap/index.d.ts +38 -0
- package/dist/minimap/index.js +69 -0
- package/dist/minimap/minimap.d.ts +35 -0
- package/dist/minimap/minimap.js +166 -0
- package/dist/optimize/index.d.ts +21 -0
- package/dist/optimize/index.js +304 -0
- package/dist/process-runner/css.d.ts +2 -0
- package/dist/process-runner/css.js +467 -0
- package/dist/process-runner/index.d.ts +56 -0
- package/dist/process-runner/index.js +549 -0
- package/dist/storage/auto-save.d.ts +11 -0
- package/dist/storage/auto-save.js +44 -0
- package/dist/storage/css.d.ts +2 -0
- package/dist/storage/css.js +2 -0
- package/dist/storage/db.d.ts +99 -0
- package/dist/storage/db.js +116 -0
- package/dist/storage/dialog.d.ts +15 -0
- package/dist/storage/dialog.js +201 -0
- package/dist/storage/export.d.ts +3 -0
- package/dist/storage/export.js +137 -0
- package/dist/storage/index.d.ts +44 -0
- package/dist/storage/index.js +201 -0
- package/dist/storage/sidebar.d.ts +2 -0
- package/dist/storage/sidebar.js +2 -0
- package/dist/storage/storage-api.d.ts +76 -0
- package/dist/storage/storage-api.js +342 -0
- package/dist/storage/types.d.ts +44 -0
- package/dist/storage/types.js +2 -0
- package/dist/storage-tabs-bridge/index.d.ts +96 -0
- package/dist/storage-tabs-bridge/index.js +502 -0
- package/dist/tabs/css.d.ts +3 -0
- package/dist/tabs/css.js +642 -0
- package/dist/tabs/file-resolver.d.ts +71 -0
- package/dist/tabs/file-resolver.js +46 -0
- package/dist/tabs/index.d.ts +15 -0
- package/dist/tabs/index.js +13 -0
- package/dist/tabs/tabs-plugin.d.ts +250 -0
- package/dist/tabs/tabs-plugin.js +1119 -0
- package/dist/token-highlight/css.d.ts +2 -0
- package/dist/token-highlight/css.js +81 -0
- package/dist/token-highlight/index.d.ts +44 -0
- package/dist/token-highlight/index.js +164 -0
- package/dist/watermark/css.d.ts +10 -0
- package/dist/watermark/css.js +54 -0
- package/dist/watermark/index.d.ts +48 -0
- package/dist/watermark/index.js +64 -0
- package/dist/zoom-controls/css.d.ts +4 -0
- package/dist/zoom-controls/css.js +48 -0
- package/dist/zoom-controls/index.d.ts +36 -0
- package/dist/zoom-controls/index.js +111 -0
- package/package.json +121 -0
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { CanvasPlugin } from "@bpmnkit/canvas";
|
|
2
|
+
export interface ElementDocsOptions {
|
|
3
|
+
/** The container element (e.g. dock.docsPane) to mount the docs panel into. */
|
|
4
|
+
container: HTMLElement;
|
|
5
|
+
}
|
|
6
|
+
export declare function createElementDocsPlugin(options: ElementDocsOptions): CanvasPlugin;
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,643 @@
|
|
|
1
|
+
import { CATEGORIES, ENTRIES } from "./content.js";
|
|
2
|
+
// ── Styles ──────────────────────────────────────────────────────────────────
|
|
3
|
+
const STYLE_ID = "bpmnkit-element-docs-styles";
|
|
4
|
+
const CSS = `
|
|
5
|
+
.bpmnkit-edocs {
|
|
6
|
+
display: flex; flex-direction: column; height: 100%; overflow: hidden;
|
|
7
|
+
font-family: system-ui, -apple-system, sans-serif;
|
|
8
|
+
color: rgba(255,255,255,0.85);
|
|
9
|
+
font-size: 13px;
|
|
10
|
+
}
|
|
11
|
+
.bpmnkit-edocs__search {
|
|
12
|
+
padding: 10px 12px 8px;
|
|
13
|
+
flex-shrink: 0;
|
|
14
|
+
}
|
|
15
|
+
.bpmnkit-edocs__search input {
|
|
16
|
+
width: 100%; box-sizing: border-box;
|
|
17
|
+
background: rgba(255,255,255,0.07); border: 1px solid rgba(255,255,255,0.12);
|
|
18
|
+
border-radius: 6px; padding: 6px 10px;
|
|
19
|
+
color: rgba(255,255,255,0.85); font-size: 12px; outline: none;
|
|
20
|
+
font-family: inherit;
|
|
21
|
+
}
|
|
22
|
+
.bpmnkit-edocs__search input::placeholder { color: rgba(255,255,255,0.3); }
|
|
23
|
+
.bpmnkit-edocs__search input:focus { border-color: #4c8ef7; background: rgba(76,142,247,0.08); }
|
|
24
|
+
.bpmnkit-edocs__body { flex: 1; overflow-y: auto; padding: 0 0 16px; }
|
|
25
|
+
/* ── Category ── */
|
|
26
|
+
.bpmnkit-edocs__cat-label {
|
|
27
|
+
font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.1em;
|
|
28
|
+
color: rgba(255,255,255,0.3); padding: 12px 12px 4px; position: sticky; top: 0;
|
|
29
|
+
background: rgba(18,18,26,0.98); z-index: 1;
|
|
30
|
+
}
|
|
31
|
+
/* ── Index items ── */
|
|
32
|
+
.bpmnkit-edocs__item {
|
|
33
|
+
display: flex; flex-direction: column; gap: 2px;
|
|
34
|
+
padding: 7px 12px; cursor: pointer;
|
|
35
|
+
border-left: 2px solid transparent;
|
|
36
|
+
transition: background 0.1s, border-color 0.1s;
|
|
37
|
+
}
|
|
38
|
+
.bpmnkit-edocs__item:hover { background: rgba(255,255,255,0.05); border-left-color: #4c8ef7; }
|
|
39
|
+
.bpmnkit-edocs__item.active { background: rgba(76,142,247,0.1); border-left-color: #4c8ef7; }
|
|
40
|
+
.bpmnkit-edocs__item-title { font-size: 12px; font-weight: 600; color: rgba(255,255,255,0.85); }
|
|
41
|
+
.bpmnkit-edocs__item-brief { font-size: 11px; color: rgba(255,255,255,0.35); }
|
|
42
|
+
/* ── Detail view ── */
|
|
43
|
+
.bpmnkit-edocs__detail { display: flex; flex-direction: column; height: 100%; }
|
|
44
|
+
.bpmnkit-edocs__detail-header {
|
|
45
|
+
display: flex; align-items: center; gap: 8px;
|
|
46
|
+
padding: 10px 12px 10px; flex-shrink: 0;
|
|
47
|
+
border-bottom: 1px solid rgba(255,255,255,0.07);
|
|
48
|
+
}
|
|
49
|
+
.bpmnkit-edocs__back {
|
|
50
|
+
background: none; border: none; cursor: pointer;
|
|
51
|
+
color: #4c8ef7; font-size: 18px; line-height: 1;
|
|
52
|
+
padding: 0 4px 0 0; display: flex; align-items: center;
|
|
53
|
+
flex-shrink: 0;
|
|
54
|
+
}
|
|
55
|
+
.bpmnkit-edocs__back:hover { color: #7db0ff; }
|
|
56
|
+
.bpmnkit-edocs__detail-title {
|
|
57
|
+
font-size: 13px; font-weight: 700; color: rgba(255,255,255,0.9); flex: 1; min-width: 0;
|
|
58
|
+
}
|
|
59
|
+
.bpmnkit-edocs__detail-subtitle { font-size: 10px; color: rgba(255,255,255,0.3); margin-top: 1px; }
|
|
60
|
+
.bpmnkit-edocs__shape-icon {
|
|
61
|
+
flex-shrink: 0; display: flex; align-items: center; justify-content: center;
|
|
62
|
+
width: 36px; height: 36px; color: rgba(255,255,255,0.6);
|
|
63
|
+
}
|
|
64
|
+
.bpmnkit-edocs__detail-body {
|
|
65
|
+
flex: 1; overflow-y: auto;
|
|
66
|
+
padding: 14px 14px 24px;
|
|
67
|
+
line-height: 1.6;
|
|
68
|
+
}
|
|
69
|
+
/* ── Markdown rendered content ── */
|
|
70
|
+
.bpmnkit-edocs__md h2 {
|
|
71
|
+
font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em;
|
|
72
|
+
color: rgba(255,255,255,0.4); margin: 18px 0 6px; padding: 0;
|
|
73
|
+
}
|
|
74
|
+
.bpmnkit-edocs__md h3 {
|
|
75
|
+
font-size: 12px; font-weight: 600; color: rgba(255,255,255,0.7);
|
|
76
|
+
margin: 14px 0 4px;
|
|
77
|
+
}
|
|
78
|
+
.bpmnkit-edocs__md p { margin: 0 0 8px; color: rgba(255,255,255,0.75); font-size: 12.5px; }
|
|
79
|
+
.bpmnkit-edocs__md ul, .bpmnkit-edocs__md ol {
|
|
80
|
+
margin: 0 0 8px; padding-left: 18px; color: rgba(255,255,255,0.75); font-size: 12.5px;
|
|
81
|
+
}
|
|
82
|
+
.bpmnkit-edocs__md li { margin-bottom: 3px; }
|
|
83
|
+
.bpmnkit-edocs__md code {
|
|
84
|
+
font-family: ui-monospace, "Cascadia Code", "SF Mono", monospace;
|
|
85
|
+
font-size: 11px; background: rgba(255,255,255,0.08);
|
|
86
|
+
border-radius: 3px; padding: 1px 5px; color: #a5d6ff;
|
|
87
|
+
}
|
|
88
|
+
.bpmnkit-edocs__md pre {
|
|
89
|
+
background: rgba(0,0,0,0.35); border: 1px solid rgba(255,255,255,0.08);
|
|
90
|
+
border-radius: 6px; padding: 10px 12px; overflow-x: auto; margin: 0 0 10px;
|
|
91
|
+
}
|
|
92
|
+
.bpmnkit-edocs__md pre code {
|
|
93
|
+
background: none; padding: 0; font-size: 11px; color: #c9d1d9;
|
|
94
|
+
}
|
|
95
|
+
.bpmnkit-edocs__md blockquote {
|
|
96
|
+
border-left: 3px solid #4c8ef7; margin: 0 0 10px; padding: 6px 10px;
|
|
97
|
+
background: rgba(76,142,247,0.08); border-radius: 0 4px 4px 0;
|
|
98
|
+
color: rgba(255,255,255,0.65); font-size: 12px;
|
|
99
|
+
}
|
|
100
|
+
.bpmnkit-edocs__md blockquote p { margin: 0; color: inherit; font-size: inherit; }
|
|
101
|
+
.bpmnkit-edocs__md table {
|
|
102
|
+
width: 100%; border-collapse: collapse; font-size: 11.5px; margin: 0 0 10px;
|
|
103
|
+
}
|
|
104
|
+
.bpmnkit-edocs__md th {
|
|
105
|
+
text-align: left; padding: 5px 8px;
|
|
106
|
+
background: rgba(255,255,255,0.06); color: rgba(255,255,255,0.5);
|
|
107
|
+
font-weight: 600; border-bottom: 1px solid rgba(255,255,255,0.08);
|
|
108
|
+
}
|
|
109
|
+
.bpmnkit-edocs__md td {
|
|
110
|
+
padding: 5px 8px; border-bottom: 1px solid rgba(255,255,255,0.05);
|
|
111
|
+
color: rgba(255,255,255,0.75);
|
|
112
|
+
}
|
|
113
|
+
.bpmnkit-edocs__md strong { color: rgba(255,255,255,0.92); font-weight: 600; }
|
|
114
|
+
.bpmnkit-edocs__md em { color: rgba(255,255,255,0.75); font-style: italic; }
|
|
115
|
+
.bpmnkit-edocs__md hr {
|
|
116
|
+
border: none; border-top: 1px solid rgba(255,255,255,0.08); margin: 14px 0;
|
|
117
|
+
}
|
|
118
|
+
/* Light theme */
|
|
119
|
+
[data-bpmnkit-hud-theme="light"] .bpmnkit-edocs {
|
|
120
|
+
color: rgba(0,0,0,0.8);
|
|
121
|
+
}
|
|
122
|
+
[data-bpmnkit-hud-theme="light"] .bpmnkit-edocs__search input {
|
|
123
|
+
background: rgba(0,0,0,0.05); border-color: rgba(0,0,0,0.12);
|
|
124
|
+
color: rgba(0,0,0,0.8);
|
|
125
|
+
}
|
|
126
|
+
[data-bpmnkit-hud-theme="light"] .bpmnkit-edocs__search input::placeholder { color: rgba(0,0,0,0.3); }
|
|
127
|
+
[data-bpmnkit-hud-theme="light"] .bpmnkit-edocs__search input:focus { border-color: #1a56db; background: rgba(26,86,219,0.05); }
|
|
128
|
+
[data-bpmnkit-hud-theme="light"] .bpmnkit-edocs__cat-label { color: rgba(0,0,0,0.3); background: rgba(248,248,252,0.99); }
|
|
129
|
+
[data-bpmnkit-hud-theme="light"] .bpmnkit-edocs__item:hover { background: rgba(0,0,0,0.04); border-left-color: #1a56db; }
|
|
130
|
+
[data-bpmnkit-hud-theme="light"] .bpmnkit-edocs__item.active { background: rgba(26,86,219,0.07); border-left-color: #1a56db; }
|
|
131
|
+
[data-bpmnkit-hud-theme="light"] .bpmnkit-edocs__item-title { color: rgba(0,0,0,0.8); }
|
|
132
|
+
[data-bpmnkit-hud-theme="light"] .bpmnkit-edocs__item-brief { color: rgba(0,0,0,0.35); }
|
|
133
|
+
[data-bpmnkit-hud-theme="light"] .bpmnkit-edocs__back { color: #1a56db; }
|
|
134
|
+
[data-bpmnkit-hud-theme="light"] .bpmnkit-edocs__back:hover { color: #1247b8; }
|
|
135
|
+
[data-bpmnkit-hud-theme="light"] .bpmnkit-edocs__detail-title { color: rgba(0,0,0,0.85); }
|
|
136
|
+
[data-bpmnkit-hud-theme="light"] .bpmnkit-edocs__detail-subtitle { color: rgba(0,0,0,0.3); }
|
|
137
|
+
[data-bpmnkit-hud-theme="light"] .bpmnkit-edocs__md h2 { color: rgba(0,0,0,0.35); }
|
|
138
|
+
[data-bpmnkit-hud-theme="light"] .bpmnkit-edocs__md h3 { color: rgba(0,0,0,0.65); }
|
|
139
|
+
[data-bpmnkit-hud-theme="light"] .bpmnkit-edocs__md p,
|
|
140
|
+
[data-bpmnkit-hud-theme="light"] .bpmnkit-edocs__md ul,
|
|
141
|
+
[data-bpmnkit-hud-theme="light"] .bpmnkit-edocs__md ol,
|
|
142
|
+
[data-bpmnkit-hud-theme="light"] .bpmnkit-edocs__md li { color: rgba(0,0,0,0.75); }
|
|
143
|
+
[data-bpmnkit-hud-theme="light"] .bpmnkit-edocs__md code { background: rgba(0,0,0,0.07); color: #0055aa; }
|
|
144
|
+
[data-bpmnkit-hud-theme="light"] .bpmnkit-edocs__md pre { background: rgba(0,0,0,0.04); border-color: rgba(0,0,0,0.08); }
|
|
145
|
+
[data-bpmnkit-hud-theme="light"] .bpmnkit-edocs__md pre code { color: #24292e; }
|
|
146
|
+
[data-bpmnkit-hud-theme="light"] .bpmnkit-edocs__md blockquote {
|
|
147
|
+
border-left-color: #1a56db; background: rgba(26,86,219,0.06); color: rgba(0,0,0,0.65);
|
|
148
|
+
}
|
|
149
|
+
[data-bpmnkit-hud-theme="light"] .bpmnkit-edocs__md th { background: rgba(0,0,0,0.04); color: rgba(0,0,0,0.5); }
|
|
150
|
+
[data-bpmnkit-hud-theme="light"] .bpmnkit-edocs__md td { color: rgba(0,0,0,0.75); }
|
|
151
|
+
[data-bpmnkit-hud-theme="light"] .bpmnkit-edocs__md strong { color: rgba(0,0,0,0.88); }
|
|
152
|
+
[data-bpmnkit-hud-theme="light"] .bpmnkit-edocs__md em { color: rgba(0,0,0,0.65); }
|
|
153
|
+
[data-bpmnkit-hud-theme="light"] .bpmnkit-edocs__md hr { border-top-color: rgba(0,0,0,0.08); }
|
|
154
|
+
[data-bpmnkit-hud-theme="light"] .bpmnkit-edocs__detail-header { border-bottom-color: rgba(0,0,0,0.07); }
|
|
155
|
+
[data-bpmnkit-hud-theme="light"] .bpmnkit-edocs__shape-icon { color: rgba(0,0,0,0.55); }
|
|
156
|
+
`;
|
|
157
|
+
function injectStyles() {
|
|
158
|
+
if (document.getElementById(STYLE_ID))
|
|
159
|
+
return;
|
|
160
|
+
const s = document.createElement("style");
|
|
161
|
+
s.id = STYLE_ID;
|
|
162
|
+
s.textContent = CSS;
|
|
163
|
+
document.head.appendChild(s);
|
|
164
|
+
}
|
|
165
|
+
// ── Markdown renderer ────────────────────────────────────────────────────────
|
|
166
|
+
function renderMarkdown(md) {
|
|
167
|
+
const lines = md.split("\n");
|
|
168
|
+
const out = [];
|
|
169
|
+
let i = 0;
|
|
170
|
+
function esc(t) {
|
|
171
|
+
return t.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
172
|
+
}
|
|
173
|
+
function inline(raw) {
|
|
174
|
+
// code (before bold/italic to avoid double-processing)
|
|
175
|
+
let t = raw.replace(/`([^`]+)`/g, (_, c) => `<code>${esc(c)}</code>`);
|
|
176
|
+
// bold
|
|
177
|
+
t = t.replace(/\*\*([^*]+)\*\*/g, "<strong>$1</strong>");
|
|
178
|
+
// italic (underscore)
|
|
179
|
+
t = t.replace(/_([^_]+)_/g, "<em>$1</em>");
|
|
180
|
+
return t;
|
|
181
|
+
}
|
|
182
|
+
while (i < lines.length) {
|
|
183
|
+
const line = lines[i] ?? "";
|
|
184
|
+
// Fenced code block
|
|
185
|
+
if (line.startsWith("```")) {
|
|
186
|
+
const lang = line.slice(3).trim();
|
|
187
|
+
const codeLines = [];
|
|
188
|
+
i++;
|
|
189
|
+
while (i < lines.length && !(lines[i] ?? "").startsWith("```")) {
|
|
190
|
+
codeLines.push(esc(lines[i] ?? ""));
|
|
191
|
+
i++;
|
|
192
|
+
}
|
|
193
|
+
const langAttr = lang ? ` class="language-${esc(lang)}"` : "";
|
|
194
|
+
out.push(`<pre><code${langAttr}>${codeLines.join("\n")}</code></pre>`);
|
|
195
|
+
i++;
|
|
196
|
+
continue;
|
|
197
|
+
}
|
|
198
|
+
// Table (lines containing |)
|
|
199
|
+
if (line.includes("|") && (lines[i + 1] ?? "").includes("---")) {
|
|
200
|
+
const headers = line
|
|
201
|
+
.split("|")
|
|
202
|
+
.filter((c) => c.trim() !== "")
|
|
203
|
+
.map((c) => `<th>${inline(c.trim())}</th>`)
|
|
204
|
+
.join("");
|
|
205
|
+
i += 2; // skip header + separator
|
|
206
|
+
const rows = [];
|
|
207
|
+
while (i < lines.length && (lines[i] ?? "").includes("|")) {
|
|
208
|
+
const cells = (lines[i] ?? "")
|
|
209
|
+
.split("|")
|
|
210
|
+
.filter((c) => c.trim() !== "")
|
|
211
|
+
.map((c) => `<td>${inline(c.trim())}</td>`)
|
|
212
|
+
.join("");
|
|
213
|
+
rows.push(`<tr>${cells}</tr>`);
|
|
214
|
+
i++;
|
|
215
|
+
}
|
|
216
|
+
out.push(`<table><thead><tr>${headers}</tr></thead><tbody>${rows.join("")}</tbody></table>`);
|
|
217
|
+
continue;
|
|
218
|
+
}
|
|
219
|
+
// Heading
|
|
220
|
+
if (line.startsWith("## ")) {
|
|
221
|
+
out.push(`<h2>${inline(esc(line.slice(3)))}</h2>`);
|
|
222
|
+
i++;
|
|
223
|
+
continue;
|
|
224
|
+
}
|
|
225
|
+
if (line.startsWith("### ")) {
|
|
226
|
+
out.push(`<h3>${inline(esc(line.slice(4)))}</h3>`);
|
|
227
|
+
i++;
|
|
228
|
+
continue;
|
|
229
|
+
}
|
|
230
|
+
// Blockquote
|
|
231
|
+
if (line.startsWith("> ")) {
|
|
232
|
+
const bqLines = [];
|
|
233
|
+
while (i < lines.length && (lines[i] ?? "").startsWith("> ")) {
|
|
234
|
+
bqLines.push(inline(esc((lines[i] ?? "").slice(2))));
|
|
235
|
+
i++;
|
|
236
|
+
}
|
|
237
|
+
out.push(`<blockquote><p>${bqLines.join("<br>")}</p></blockquote>`);
|
|
238
|
+
continue;
|
|
239
|
+
}
|
|
240
|
+
// Unordered list
|
|
241
|
+
if (line.startsWith("- ")) {
|
|
242
|
+
const items = [];
|
|
243
|
+
while (i < lines.length && (lines[i] ?? "").startsWith("- ")) {
|
|
244
|
+
items.push(`<li>${inline(esc((lines[i] ?? "").slice(2)))}</li>`);
|
|
245
|
+
i++;
|
|
246
|
+
}
|
|
247
|
+
out.push(`<ul>${items.join("")}</ul>`);
|
|
248
|
+
continue;
|
|
249
|
+
}
|
|
250
|
+
// Numbered list
|
|
251
|
+
if (/^\d+\. /.test(line)) {
|
|
252
|
+
const items = [];
|
|
253
|
+
while (i < lines.length && /^\d+\. /.test(lines[i] ?? "")) {
|
|
254
|
+
items.push(`<li>${inline(esc((lines[i] ?? "").replace(/^\d+\. /, "")))}</li>`);
|
|
255
|
+
i++;
|
|
256
|
+
}
|
|
257
|
+
out.push(`<ol>${items.join("")}</ol>`);
|
|
258
|
+
continue;
|
|
259
|
+
}
|
|
260
|
+
// Horizontal rule
|
|
261
|
+
if (line.startsWith("---")) {
|
|
262
|
+
out.push("<hr>");
|
|
263
|
+
i++;
|
|
264
|
+
continue;
|
|
265
|
+
}
|
|
266
|
+
// Empty line — paragraph break
|
|
267
|
+
if (line.trim() === "") {
|
|
268
|
+
i++;
|
|
269
|
+
continue;
|
|
270
|
+
}
|
|
271
|
+
// Paragraph — collect until empty line or block element
|
|
272
|
+
const paraLines = [];
|
|
273
|
+
while (i < lines.length &&
|
|
274
|
+
(lines[i] ?? "").trim() !== "" &&
|
|
275
|
+
!(lines[i] ?? "").startsWith("#") &&
|
|
276
|
+
!(lines[i] ?? "").startsWith("> ") &&
|
|
277
|
+
!(lines[i] ?? "").startsWith("- ") &&
|
|
278
|
+
!(lines[i] ?? "").startsWith("```") &&
|
|
279
|
+
!/^\d+\. /.test(lines[i] ?? "")) {
|
|
280
|
+
paraLines.push(inline(esc(lines[i] ?? "")));
|
|
281
|
+
i++;
|
|
282
|
+
}
|
|
283
|
+
if (paraLines.length > 0) {
|
|
284
|
+
out.push(`<p>${paraLines.join(" ")}</p>`);
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
return out.join("\n");
|
|
288
|
+
}
|
|
289
|
+
// ── SVG shape icons ──────────────────────────────────────────────────────────
|
|
290
|
+
function getShapeIcon(docKey) {
|
|
291
|
+
const [base, sub] = docKey.split(":");
|
|
292
|
+
const W = 36;
|
|
293
|
+
const H = 36;
|
|
294
|
+
const cx = W / 2;
|
|
295
|
+
const cy = H / 2;
|
|
296
|
+
const r = 14;
|
|
297
|
+
// Event fill/stroke helper
|
|
298
|
+
function event(inner, dashed = false, thick = false) {
|
|
299
|
+
const sw = thick ? 3 : 1.5;
|
|
300
|
+
const dash = dashed ? ' stroke-dasharray="4 2"' : "";
|
|
301
|
+
return `<svg xmlns="http://www.w3.org/2000/svg" width="${W}" height="${H}" viewBox="0 0 ${W} ${H}">
|
|
302
|
+
<circle cx="${cx}" cy="${cy}" r="${r}" fill="none" stroke="currentColor" stroke-width="${sw}"${dash}/>
|
|
303
|
+
${inner}
|
|
304
|
+
</svg>`;
|
|
305
|
+
}
|
|
306
|
+
function doubleRing(inner) {
|
|
307
|
+
return `<svg xmlns="http://www.w3.org/2000/svg" width="${W}" height="${H}" viewBox="0 0 ${W} ${H}">
|
|
308
|
+
<circle cx="${cx}" cy="${cy}" r="${r}" fill="none" stroke="currentColor" stroke-width="1.5"/>
|
|
309
|
+
<circle cx="${cx}" cy="${cy}" r="${r - 3}" fill="none" stroke="currentColor" stroke-width="1.5"/>
|
|
310
|
+
${inner}
|
|
311
|
+
</svg>`;
|
|
312
|
+
}
|
|
313
|
+
function doubleRingDashed(inner) {
|
|
314
|
+
return `<svg xmlns="http://www.w3.org/2000/svg" width="${W}" height="${H}" viewBox="0 0 ${W} ${H}">
|
|
315
|
+
<circle cx="${cx}" cy="${cy}" r="${r}" fill="none" stroke="currentColor" stroke-width="1.5" stroke-dasharray="4 2"/>
|
|
316
|
+
<circle cx="${cx}" cy="${cy}" r="${r - 3}" fill="none" stroke="currentColor" stroke-width="1.5" stroke-dasharray="4 2"/>
|
|
317
|
+
${inner}
|
|
318
|
+
</svg>`;
|
|
319
|
+
}
|
|
320
|
+
const msgIcon = `<rect x="10" y="13" width="16" height="10" rx="1" fill="none" stroke="currentColor" stroke-width="1.2"/>
|
|
321
|
+
<polyline points="10,13 18,20 26,13" fill="none" stroke="currentColor" stroke-width="1.2"/>`;
|
|
322
|
+
const timerIcon = `<circle cx="${cx}" cy="${cy}" r="7" fill="none" stroke="currentColor" stroke-width="1.2"/>
|
|
323
|
+
<line x1="${cx}" y1="${cy}" x2="${cx}" y2="${cy - 5}" stroke="currentColor" stroke-width="1.2"/>
|
|
324
|
+
<line x1="${cx}" y1="${cy}" x2="${cx + 3}" y2="${cy + 3}" stroke="currentColor" stroke-width="1.2"/>`;
|
|
325
|
+
const signalIcon = `<polygon points="18,10 26,26 10,26" fill="none" stroke="currentColor" stroke-width="1.2"/>`;
|
|
326
|
+
const errorIcon = `<polyline points="12,24 16,14 20,20 24,12" fill="none" stroke="currentColor" stroke-width="1.5"/>`;
|
|
327
|
+
const escalationIcon = `<polygon points="18,11 24,25 18,21 12,25" fill="none" stroke="currentColor" stroke-width="1.2"/>`;
|
|
328
|
+
const compensateIcon = `<polygon points="10,18 17,12 17,24" fill="currentColor" opacity="0.6"/>
|
|
329
|
+
<polygon points="17,18 24,12 24,24" fill="currentColor" opacity="0.6"/>`;
|
|
330
|
+
const terminateIcon = `<circle cx="${cx}" cy="${cy}" r="8" fill="currentColor" opacity="0.8"/>`;
|
|
331
|
+
const linkIcon = `<polyline points="11,18 22,18" stroke="currentColor" stroke-width="1.5" fill="none"/>
|
|
332
|
+
<polyline points="18,13 24,18 18,23" fill="none" stroke="currentColor" stroke-width="1.5"/>`;
|
|
333
|
+
const cancelIcon = `<line x1="11" y1="11" x2="25" y2="25" stroke="currentColor" stroke-width="1.5"/>
|
|
334
|
+
<line x1="25" y1="11" x2="11" y2="25" stroke="currentColor" stroke-width="1.5"/>`;
|
|
335
|
+
// Gateway
|
|
336
|
+
function gateway(icon) {
|
|
337
|
+
return `<svg xmlns="http://www.w3.org/2000/svg" width="${W}" height="${H}" viewBox="0 0 ${W} ${H}">
|
|
338
|
+
<polygon points="18,4 32,18 18,32 4,18" fill="none" stroke="currentColor" stroke-width="1.5"/>
|
|
339
|
+
${icon}
|
|
340
|
+
</svg>`;
|
|
341
|
+
}
|
|
342
|
+
// Task rectangle
|
|
343
|
+
function task(icon) {
|
|
344
|
+
return `<svg xmlns="http://www.w3.org/2000/svg" width="${W}" height="${H}" viewBox="0 0 ${W} ${H}">
|
|
345
|
+
<rect x="3" y="6" width="30" height="24" rx="3" fill="none" stroke="currentColor" stroke-width="1.5"/>
|
|
346
|
+
${icon}
|
|
347
|
+
</svg>`;
|
|
348
|
+
}
|
|
349
|
+
if (base === "startEvent") {
|
|
350
|
+
const icons = {
|
|
351
|
+
message: event(msgIcon),
|
|
352
|
+
timer: event(timerIcon),
|
|
353
|
+
signal: event(signalIcon),
|
|
354
|
+
error: event(errorIcon),
|
|
355
|
+
escalation: event(escalationIcon),
|
|
356
|
+
};
|
|
357
|
+
return sub ? (icons[sub] ?? event("")) : event("");
|
|
358
|
+
}
|
|
359
|
+
if (base === "endEvent") {
|
|
360
|
+
const icons = {
|
|
361
|
+
message: event(msgIcon, false, true),
|
|
362
|
+
terminate: event(terminateIcon, false, true),
|
|
363
|
+
error: event(errorIcon, false, true),
|
|
364
|
+
signal: event(signalIcon, false, true),
|
|
365
|
+
escalation: event(escalationIcon, false, true),
|
|
366
|
+
compensation: event(compensateIcon, false, true),
|
|
367
|
+
};
|
|
368
|
+
return sub ? (icons[sub] ?? event("", false, true)) : event("", false, true);
|
|
369
|
+
}
|
|
370
|
+
if (base === "intermediateCatchEvent") {
|
|
371
|
+
const icons = {
|
|
372
|
+
message: doubleRing(msgIcon),
|
|
373
|
+
timer: doubleRing(timerIcon),
|
|
374
|
+
signal: doubleRing(signalIcon),
|
|
375
|
+
link: doubleRing(linkIcon),
|
|
376
|
+
};
|
|
377
|
+
return sub ? (icons[sub] ?? doubleRing("")) : doubleRing("");
|
|
378
|
+
}
|
|
379
|
+
if (base === "intermediateThrowEvent") {
|
|
380
|
+
const icons = {
|
|
381
|
+
message: doubleRing(`<rect x="10" y="13" width="16" height="10" rx="1" fill="currentColor" opacity="0.4" stroke="currentColor" stroke-width="1.2"/>`),
|
|
382
|
+
signal: doubleRing(`<polygon points="18,10 26,26 10,26" fill="currentColor" opacity="0.4" stroke="currentColor" stroke-width="1.2"/>`),
|
|
383
|
+
escalation: doubleRing(escalationIcon),
|
|
384
|
+
compensation: doubleRing(compensateIcon),
|
|
385
|
+
link: doubleRing(linkIcon),
|
|
386
|
+
};
|
|
387
|
+
return sub ? (icons[sub] ?? doubleRing("")) : doubleRing("");
|
|
388
|
+
}
|
|
389
|
+
if (base === "boundaryEvent") {
|
|
390
|
+
const icons = {
|
|
391
|
+
message: doubleRing(msgIcon),
|
|
392
|
+
timer: doubleRing(timerIcon),
|
|
393
|
+
error: doubleRing(errorIcon),
|
|
394
|
+
signal: doubleRing(signalIcon),
|
|
395
|
+
timer_escalation: doubleRingDashed(escalationIcon),
|
|
396
|
+
compensation: doubleRing(compensateIcon),
|
|
397
|
+
cancel: doubleRing(cancelIcon),
|
|
398
|
+
};
|
|
399
|
+
return sub ? (icons[sub] ?? doubleRing("")) : doubleRing("");
|
|
400
|
+
}
|
|
401
|
+
if (base === "exclusiveGateway") {
|
|
402
|
+
return gateway(`<line x1="12" y1="12" x2="24" y2="24" stroke="currentColor" stroke-width="2"/>
|
|
403
|
+
<line x1="24" y1="12" x2="12" y2="24" stroke="currentColor" stroke-width="2"/>`);
|
|
404
|
+
}
|
|
405
|
+
if (base === "parallelGateway") {
|
|
406
|
+
return gateway(`<line x1="18" y1="10" x2="18" y2="26" stroke="currentColor" stroke-width="2"/>
|
|
407
|
+
<line x1="10" y1="18" x2="26" y2="18" stroke="currentColor" stroke-width="2"/>`);
|
|
408
|
+
}
|
|
409
|
+
if (base === "inclusiveGateway") {
|
|
410
|
+
return gateway(`<circle cx="18" cy="18" r="5" fill="none" stroke="currentColor" stroke-width="2"/>`);
|
|
411
|
+
}
|
|
412
|
+
if (base === "eventBasedGateway") {
|
|
413
|
+
return gateway(`<circle cx="18" cy="18" r="6" fill="none" stroke="currentColor" stroke-width="1.2"/>
|
|
414
|
+
<polygon points="18,12 21,17 27,17 22,21 24,27 18,23 12,27 14,21 9,17 15,17" fill="none" stroke="currentColor" stroke-width="1"/>`);
|
|
415
|
+
}
|
|
416
|
+
if (base === "serviceTask")
|
|
417
|
+
return task(`<text x="18" y="22" text-anchor="middle" font-size="11" fill="currentColor" opacity="0.7">âš™</text>`);
|
|
418
|
+
if (base === "userTask")
|
|
419
|
+
return task(`<text x="18" y="22" text-anchor="middle" font-size="11" fill="currentColor" opacity="0.7">👤</text>`);
|
|
420
|
+
if (base === "businessRuleTask")
|
|
421
|
+
return task(`<text x="18" y="22" text-anchor="middle" font-size="9" fill="currentColor" opacity="0.7">≡</text>`);
|
|
422
|
+
if (base === "scriptTask")
|
|
423
|
+
return task(`<text x="18" y="22" text-anchor="middle" font-size="11" fill="currentColor" opacity="0.7">{}</text>`);
|
|
424
|
+
if (base === "sendTask")
|
|
425
|
+
return task(`<rect x="10" y="13" width="16" height="10" rx="1" fill="currentColor" opacity="0.3" stroke="currentColor" stroke-width="1.2"/>`);
|
|
426
|
+
if (base === "receiveTask")
|
|
427
|
+
return task(`<rect x="10" y="13" width="16" height="10" rx="1" fill="none" stroke="currentColor" stroke-width="1.2"/>`);
|
|
428
|
+
if (base === "manualTask")
|
|
429
|
+
return task(`<text x="18" y="22" text-anchor="middle" font-size="11" fill="currentColor" opacity="0.7">✋</text>`);
|
|
430
|
+
if (base === "callActivity") {
|
|
431
|
+
return `<svg xmlns="http://www.w3.org/2000/svg" width="${W}" height="${H}" viewBox="0 0 ${W} ${H}">
|
|
432
|
+
<rect x="3" y="6" width="30" height="24" rx="3" fill="none" stroke="currentColor" stroke-width="2"/>
|
|
433
|
+
<rect x="12" y="22" width="12" height="6" rx="1" fill="none" stroke="currentColor" stroke-width="1.2"/>
|
|
434
|
+
</svg>`;
|
|
435
|
+
}
|
|
436
|
+
if (base === "subProcess") {
|
|
437
|
+
return `<svg xmlns="http://www.w3.org/2000/svg" width="${W}" height="${H}" viewBox="0 0 ${W} ${H}">
|
|
438
|
+
<rect x="3" y="6" width="30" height="24" rx="3" fill="none" stroke="currentColor" stroke-width="1.5"/>
|
|
439
|
+
<rect x="15" y="24" width="6" height="4" rx="1" fill="none" stroke="currentColor" stroke-width="1.2"/>
|
|
440
|
+
<line x1="18" y1="24" x2="18" y2="26" stroke="currentColor" stroke-width="1.2"/>
|
|
441
|
+
<line x1="15" y1="26" x2="21" y2="26" stroke="currentColor" stroke-width="1.2"/>
|
|
442
|
+
</svg>`;
|
|
443
|
+
}
|
|
444
|
+
if (base === "adHocSubProcess") {
|
|
445
|
+
return `<svg xmlns="http://www.w3.org/2000/svg" width="${W}" height="${H}" viewBox="0 0 ${W} ${H}">
|
|
446
|
+
<rect x="3" y="6" width="30" height="24" rx="3" fill="none" stroke="currentColor" stroke-width="1.5" stroke-dasharray="5 2"/>
|
|
447
|
+
<text x="18" y="23" text-anchor="middle" font-size="10" fill="currentColor" opacity="0.6">~</text>
|
|
448
|
+
</svg>`;
|
|
449
|
+
}
|
|
450
|
+
if (base === "sequenceFlow") {
|
|
451
|
+
return `<svg xmlns="http://www.w3.org/2000/svg" width="${W}" height="${H}" viewBox="0 0 ${W} ${H}">
|
|
452
|
+
<line x1="6" y1="18" x2="28" y2="18" stroke="currentColor" stroke-width="1.5"/>
|
|
453
|
+
<polygon points="28,14 36,18 28,22" fill="currentColor"/>
|
|
454
|
+
</svg>`;
|
|
455
|
+
}
|
|
456
|
+
return `<svg xmlns="http://www.w3.org/2000/svg" width="${W}" height="${H}" viewBox="0 0 ${W} ${H}">
|
|
457
|
+
<rect x="3" y="6" width="30" height="24" rx="3" fill="none" stroke="currentColor" stroke-width="1.5"/>
|
|
458
|
+
</svg>`;
|
|
459
|
+
}
|
|
460
|
+
// ── Doc key from BpmnFlowElement ─────────────────────────────────────────────
|
|
461
|
+
function docKeyFromElement(el) {
|
|
462
|
+
if (el.type === "startEvent" ||
|
|
463
|
+
el.type === "endEvent" ||
|
|
464
|
+
el.type === "intermediateCatchEvent" ||
|
|
465
|
+
el.type === "intermediateThrowEvent" ||
|
|
466
|
+
el.type === "boundaryEvent") {
|
|
467
|
+
const evDef = el.eventDefinitions[0];
|
|
468
|
+
if (evDef)
|
|
469
|
+
return `${el.type}:${evDef.type}`;
|
|
470
|
+
}
|
|
471
|
+
return el.type;
|
|
472
|
+
}
|
|
473
|
+
export function createElementDocsPlugin(options) {
|
|
474
|
+
injectStyles();
|
|
475
|
+
const { container } = options;
|
|
476
|
+
// ── Root UI ──────────────────────────────────────────────────────────────
|
|
477
|
+
const root = document.createElement("div");
|
|
478
|
+
root.className = "bpmnkit-edocs";
|
|
479
|
+
// Search bar (only shown in index view)
|
|
480
|
+
const searchWrap = document.createElement("div");
|
|
481
|
+
searchWrap.className = "bpmnkit-edocs__search";
|
|
482
|
+
const searchInput = document.createElement("input");
|
|
483
|
+
searchInput.type = "search";
|
|
484
|
+
searchInput.placeholder = "Search elements…";
|
|
485
|
+
searchInput.setAttribute("aria-label", "Search BPMN elements");
|
|
486
|
+
searchWrap.appendChild(searchInput);
|
|
487
|
+
// Scrollable body
|
|
488
|
+
const body = document.createElement("div");
|
|
489
|
+
body.className = "bpmnkit-edocs__body";
|
|
490
|
+
root.appendChild(searchWrap);
|
|
491
|
+
root.appendChild(body);
|
|
492
|
+
container.appendChild(root);
|
|
493
|
+
// ── State ────────────────────────────────────────────────────────────────
|
|
494
|
+
let _currentKey = null;
|
|
495
|
+
let _query = "";
|
|
496
|
+
// ── Index rendering ──────────────────────────────────────────────────────
|
|
497
|
+
function renderIndex(query) {
|
|
498
|
+
searchWrap.style.display = "";
|
|
499
|
+
body.innerHTML = "";
|
|
500
|
+
const q = query.toLowerCase().trim();
|
|
501
|
+
for (const cat of CATEGORIES) {
|
|
502
|
+
const filtered = q
|
|
503
|
+
? cat.items.filter((item) => item.title.toLowerCase().includes(q) || item.brief.toLowerCase().includes(q))
|
|
504
|
+
: cat.items;
|
|
505
|
+
if (filtered.length === 0)
|
|
506
|
+
continue;
|
|
507
|
+
const catLabel = document.createElement("div");
|
|
508
|
+
catLabel.className = "bpmnkit-edocs__cat-label";
|
|
509
|
+
catLabel.textContent = cat.label;
|
|
510
|
+
body.appendChild(catLabel);
|
|
511
|
+
for (const item of filtered) {
|
|
512
|
+
const row = document.createElement("div");
|
|
513
|
+
row.className = `bpmnkit-edocs__item${_currentKey === item.key ? " active" : ""}`;
|
|
514
|
+
row.setAttribute("role", "button");
|
|
515
|
+
row.setAttribute("tabindex", "0");
|
|
516
|
+
const titleEl = document.createElement("div");
|
|
517
|
+
titleEl.className = "bpmnkit-edocs__item-title";
|
|
518
|
+
titleEl.textContent = item.title;
|
|
519
|
+
const briefEl = document.createElement("div");
|
|
520
|
+
briefEl.className = "bpmnkit-edocs__item-brief";
|
|
521
|
+
briefEl.textContent = item.brief;
|
|
522
|
+
row.appendChild(titleEl);
|
|
523
|
+
row.appendChild(briefEl);
|
|
524
|
+
row.addEventListener("click", () => showDetail(item.key));
|
|
525
|
+
row.addEventListener("keydown", (e) => {
|
|
526
|
+
if (e.key === "Enter" || e.key === " ")
|
|
527
|
+
showDetail(item.key);
|
|
528
|
+
});
|
|
529
|
+
body.appendChild(row);
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
if (body.children.length === 0) {
|
|
533
|
+
const empty = document.createElement("div");
|
|
534
|
+
empty.style.cssText =
|
|
535
|
+
"padding: 24px 12px; color: rgba(255,255,255,0.3); font-size: 12px; text-align: center;";
|
|
536
|
+
empty.textContent = "No elements match your search.";
|
|
537
|
+
body.appendChild(empty);
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
// ── Detail rendering ─────────────────────────────────────────────────────
|
|
541
|
+
function showDetail(key) {
|
|
542
|
+
_currentKey = key;
|
|
543
|
+
const entry = ENTRIES[key];
|
|
544
|
+
if (!entry) {
|
|
545
|
+
renderIndex(_query);
|
|
546
|
+
return;
|
|
547
|
+
}
|
|
548
|
+
searchWrap.style.display = "none";
|
|
549
|
+
body.innerHTML = "";
|
|
550
|
+
const detail = document.createElement("div");
|
|
551
|
+
detail.className = "bpmnkit-edocs__detail";
|
|
552
|
+
// Header: back button + icon + title
|
|
553
|
+
const header = document.createElement("div");
|
|
554
|
+
header.className = "bpmnkit-edocs__detail-header";
|
|
555
|
+
const backBtn = document.createElement("button");
|
|
556
|
+
backBtn.className = "bpmnkit-edocs__back";
|
|
557
|
+
backBtn.title = "Back to index";
|
|
558
|
+
backBtn.setAttribute("aria-label", "Back to element list");
|
|
559
|
+
backBtn.innerHTML = "‹";
|
|
560
|
+
backBtn.addEventListener("click", () => {
|
|
561
|
+
_currentKey = null;
|
|
562
|
+
renderIndex(_query);
|
|
563
|
+
});
|
|
564
|
+
const iconEl = document.createElement("div");
|
|
565
|
+
iconEl.className = "bpmnkit-edocs__shape-icon";
|
|
566
|
+
iconEl.innerHTML = getShapeIcon(key);
|
|
567
|
+
const titles = document.createElement("div");
|
|
568
|
+
titles.style.flex = "1";
|
|
569
|
+
titles.style.minWidth = "0";
|
|
570
|
+
const titleEl = document.createElement("div");
|
|
571
|
+
titleEl.className = "bpmnkit-edocs__detail-title";
|
|
572
|
+
titleEl.textContent = entry.title;
|
|
573
|
+
const subEl = document.createElement("div");
|
|
574
|
+
subEl.className = "bpmnkit-edocs__detail-subtitle";
|
|
575
|
+
subEl.textContent = entry.subtitle;
|
|
576
|
+
titles.appendChild(titleEl);
|
|
577
|
+
titles.appendChild(subEl);
|
|
578
|
+
header.appendChild(backBtn);
|
|
579
|
+
header.appendChild(iconEl);
|
|
580
|
+
header.appendChild(titles);
|
|
581
|
+
// Body: rendered markdown
|
|
582
|
+
const mdBody = document.createElement("div");
|
|
583
|
+
mdBody.className = "bpmnkit-edocs__detail-body";
|
|
584
|
+
const mdContent = document.createElement("div");
|
|
585
|
+
mdContent.className = "bpmnkit-edocs__md";
|
|
586
|
+
mdContent.innerHTML = renderMarkdown(entry.body);
|
|
587
|
+
mdBody.appendChild(mdContent);
|
|
588
|
+
detail.appendChild(header);
|
|
589
|
+
detail.appendChild(mdBody);
|
|
590
|
+
body.appendChild(detail);
|
|
591
|
+
}
|
|
592
|
+
// ── Search ───────────────────────────────────────────────────────────────
|
|
593
|
+
searchInput.addEventListener("input", () => {
|
|
594
|
+
_query = searchInput.value;
|
|
595
|
+
renderIndex(_query);
|
|
596
|
+
});
|
|
597
|
+
// ── Public API ───────────────────────────────────────────────────────────
|
|
598
|
+
/** Navigate to the doc for a given element. */
|
|
599
|
+
function showDocForElement(el) {
|
|
600
|
+
const key = docKeyFromElement(el);
|
|
601
|
+
if (ENTRIES[key]) {
|
|
602
|
+
showDetail(key);
|
|
603
|
+
}
|
|
604
|
+
else if (ENTRIES[el.type]) {
|
|
605
|
+
showDetail(el.type);
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
// Render index initially
|
|
609
|
+
renderIndex("");
|
|
610
|
+
// ── Canvas plugin ────────────────────────────────────────────────────────
|
|
611
|
+
const unsubs = [];
|
|
612
|
+
return {
|
|
613
|
+
name: "element-docs",
|
|
614
|
+
install(api) {
|
|
615
|
+
const anyOn = api.on.bind(api);
|
|
616
|
+
unsubs.push(anyOn("editor:select", (rawIds) => {
|
|
617
|
+
const ids = rawIds;
|
|
618
|
+
if (ids.length !== 1)
|
|
619
|
+
return;
|
|
620
|
+
const id = ids[0];
|
|
621
|
+
if (!id)
|
|
622
|
+
return;
|
|
623
|
+
// Find the selected element via rendered shapes
|
|
624
|
+
const shape = api.getShapes().find((s) => s.id === id);
|
|
625
|
+
if (shape?.flowElement) {
|
|
626
|
+
showDocForElement(shape.flowElement);
|
|
627
|
+
return;
|
|
628
|
+
}
|
|
629
|
+
// Sequence flows are edges, not shapes
|
|
630
|
+
const edge = api.getEdges().find((e) => e.id === id);
|
|
631
|
+
if (edge)
|
|
632
|
+
showDetail("sequenceFlow");
|
|
633
|
+
}));
|
|
634
|
+
},
|
|
635
|
+
uninstall() {
|
|
636
|
+
for (const off of unsubs)
|
|
637
|
+
off();
|
|
638
|
+
unsubs.length = 0;
|
|
639
|
+
container.removeChild(root);
|
|
640
|
+
},
|
|
641
|
+
};
|
|
642
|
+
}
|
|
643
|
+
//# sourceMappingURL=index.js.map
|