@bpmn-nova/studio 0.3.8-preview → 0.4.0
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 +2 -2
- package/dist/canvas.js +97 -25
- package/dist/config.js +42 -0
- package/dist/context-menu.js +41 -32
- package/dist/controller.js +45 -19
- package/dist/index.d.ts +59 -2
- package/dist/index.js +1 -0
- package/dist/interactions.js +6 -1
- package/dist/modules/bpmn-model/index.d.ts +2 -1
- package/dist/modules/bpmn-model/index.js +12 -10
- package/dist/modules/core/gateway.js +16 -13
- package/dist/modules/core/index.d.ts +6 -4
- package/dist/modules/core/model.js +12 -7
- package/dist/modules/designer/index.d.ts +5 -1
- package/dist/modules/designer/index.js +36 -15
- package/dist/modules/export-svg/index.d.ts +12 -5
- package/dist/modules/export-svg/preview.js +34 -24
- package/dist/modules/export-svg/render.js +102 -50
- package/dist/modules/i18n/index.d.ts +647 -0
- package/dist/modules/i18n/index.js +247 -0
- package/dist/modules/i18n/locales/en-US.js +823 -0
- package/dist/modules/i18n/locales/zh-CN.js +805 -0
- package/dist/modules/node-presentation/index.d.ts +3 -2
- package/dist/modules/node-presentation/index.js +14 -11
- package/dist/modules/palette/index.d.ts +6 -1
- package/dist/modules/palette/index.js +26 -8
- package/dist/modules/palette/panel.js +44 -6
- package/dist/modules/properties/index.d.ts +2 -1
- package/dist/modules/properties/index.js +2 -2
- package/dist/modules/properties-activiti/index.js +84 -59
- package/dist/modules/properties-bpmn/index.js +151 -128
- package/dist/modules/properties-core/index.d.ts +9 -3
- package/dist/modules/properties-core/index.js +16 -4
- package/dist/modules/properties-flowable/index.js +55 -34
- package/dist/modules/properties-renderer/index.d.ts +5 -1
- package/dist/modules/properties-renderer/index.js +110 -42
- package/dist/modules/renderer-svg/index.d.ts +6 -2
- package/dist/modules/renderer-svg/index.js +113 -38
- package/dist/modules/runtime/index.d.ts +33 -5
- package/dist/modules/runtime/index.js +97 -73
- package/dist/modules/runtime/time.js +89 -4
- package/dist/modules/runtime/visits.js +6 -4
- package/dist/modules/theme/index.d.ts +5 -2
- package/dist/modules/theme/index.js +8 -4
- package/dist/modules/viewer/index.d.ts +28 -7
- package/dist/modules/viewer/index.js +213 -56
- package/dist/modules/viewer/runtime-content.js +26 -20
- package/dist/modules/viewer/runtime-trace.js +43 -25
- package/dist/modules/viewer/timeline.js +103 -36
- package/dist/shell.js +279 -75
- package/dist/sidebars.js +3 -1
- package/dist/styles.css +6 -3
- package/llms-full.txt +296 -49
- package/llms.txt +4 -4
- package/package.json +2 -3
|
@@ -8,6 +8,7 @@ import type {
|
|
|
8
8
|
ProcessModel,
|
|
9
9
|
} from '../core/index.js'
|
|
10
10
|
import type { DiagramRenderer } from '../renderer-svg/index.js'
|
|
11
|
+
import type { I18nController, NovaI18nOptions, NovaLocale, NovaLocaleState, NovaMessagesOverride } from '../i18n/index.js'
|
|
11
12
|
import type { NovaThemeInput, NovaThemeMode, NovaThemeState, ThemeController } from '../theme/index.js'
|
|
12
13
|
import type { SvgExportArtifact, SvgExportOptions, SvgExportPreviewController, SvgNodeRenderer } from '../export-svg/index.js'
|
|
13
14
|
|
|
@@ -18,7 +19,7 @@ export interface DesignerState {
|
|
|
18
19
|
canRedo: boolean
|
|
19
20
|
engine: EngineId
|
|
20
21
|
}
|
|
21
|
-
export interface DesignerOptions {
|
|
22
|
+
export interface DesignerOptions extends NovaI18nOptions {
|
|
22
23
|
container: HTMLElement
|
|
23
24
|
model: ProcessModel
|
|
24
25
|
historyLimit?: number
|
|
@@ -35,6 +36,7 @@ export interface DesignerOptions {
|
|
|
35
36
|
export function normalizeCanvasCoordinate(value: unknown): number
|
|
36
37
|
export function canSequenceConnect(model: ProcessModel, sourceId: string, targetId: string): boolean
|
|
37
38
|
export class BpmnDesigner {
|
|
39
|
+
readonly i18n: I18nController
|
|
38
40
|
constructor(options: DesignerOptions)
|
|
39
41
|
model: ProcessModel
|
|
40
42
|
selection: ElementSelection | null
|
|
@@ -54,6 +56,8 @@ export class BpmnDesigner {
|
|
|
54
56
|
openSvgExportPreview(options?: SvgExportOptions & { previewTitle?: string; onDownload?: (artifact: SvgExportArtifact) => void }): SvgExportPreviewController
|
|
55
57
|
importXml(xml: string, engineHint?: EngineId): ProcessModel
|
|
56
58
|
validate(): Array<{ level: 'error' | 'warning'; elementId?: string; message: string }>
|
|
59
|
+
setLocale(locale?: NovaLocale | null, messages?: NovaMessagesOverride | null): NovaLocaleState
|
|
60
|
+
getLocale(): string
|
|
57
61
|
setTheme(theme: NovaThemeInput): NovaThemeState
|
|
58
62
|
setThemeMode(mode: NovaThemeMode): NovaThemeState
|
|
59
63
|
getThemeState(): NovaThemeState
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { applyContainmentOperation, createNode, createEdge, getNode, getEdge, clearConnectedWaypoints, cloneModel, HistoryStack, autoLayout, beautify, snapNodePosition, NODE_DEFINITIONS, LAYOUT_DENSITIES, resolveSwimlaneLabelPlacement, validateParallelGateway } from '../core/index.js';
|
|
2
|
+
import { createI18n, resolveI18n } from '../i18n/index.js';
|
|
2
3
|
import { DiagramRenderer } from '../renderer-svg/index.js';
|
|
3
4
|
import { importBpmn, exportBpmn } from '../bpmn-model/index.js';
|
|
4
5
|
|
|
@@ -40,6 +41,13 @@ export class BpmnDesigner {
|
|
|
40
41
|
constructor(options = {}) {
|
|
41
42
|
if (!options.container) throw new Error('BpmnDesigner requires container.');
|
|
42
43
|
this.model = options.model;
|
|
44
|
+
if (options.i18n) {
|
|
45
|
+
this.i18n = resolveI18n(options.i18n);
|
|
46
|
+
this._ownsI18n = false;
|
|
47
|
+
} else {
|
|
48
|
+
this.i18n = createI18n({ locale: options.locale, messages: options.messages });
|
|
49
|
+
this._ownsI18n = true;
|
|
50
|
+
}
|
|
43
51
|
this.onChange = options.onChange || (() => {});
|
|
44
52
|
this.onSelectionChange = options.onSelectionChange || (() => {});
|
|
45
53
|
this.onStateChange = options.onStateChange || (() => {});
|
|
@@ -53,6 +61,7 @@ export class BpmnDesigner {
|
|
|
53
61
|
themeController: options.themeController,
|
|
54
62
|
theme: options.theme,
|
|
55
63
|
onThemeChange: options.onThemeChange,
|
|
64
|
+
i18n: this.i18n,
|
|
56
65
|
svgExport: options.svgExport,
|
|
57
66
|
model: this.model,
|
|
58
67
|
mode: 'design',
|
|
@@ -79,6 +88,17 @@ export class BpmnDesigner {
|
|
|
79
88
|
this.renderer.destroy();
|
|
80
89
|
}
|
|
81
90
|
|
|
91
|
+
setLocale(locale, messages) {
|
|
92
|
+
if (!this._ownsI18n) {
|
|
93
|
+
this.i18n = createI18n({ locale: locale ?? this.i18n.locale, messages });
|
|
94
|
+
this._ownsI18n = true;
|
|
95
|
+
this.renderer.setLocale(locale, messages);
|
|
96
|
+
return this.i18n.getState();
|
|
97
|
+
}
|
|
98
|
+
return this.i18n.setLocale(locale, messages);
|
|
99
|
+
}
|
|
100
|
+
getLocale() { return this.i18n.locale; }
|
|
101
|
+
|
|
82
102
|
setTheme(theme) { return this.renderer.setTheme(theme); }
|
|
83
103
|
setThemeMode(mode) { return this.renderer.setThemeMode(mode); }
|
|
84
104
|
getThemeState() { return this.renderer.getThemeState(); }
|
|
@@ -161,7 +181,7 @@ export class BpmnDesigner {
|
|
|
161
181
|
addNode(type, x, y, overrides = {}) {
|
|
162
182
|
let created;
|
|
163
183
|
this._commit('add-node', () => {
|
|
164
|
-
created = createNode(type, x, y, overrides);
|
|
184
|
+
created = createNode(type, x, y, overrides, { i18n: this.i18n });
|
|
165
185
|
this.model.nodes.push(created);
|
|
166
186
|
});
|
|
167
187
|
this.select({ kind: 'node', id: created.id });
|
|
@@ -203,10 +223,10 @@ export class BpmnDesigner {
|
|
|
203
223
|
let created;
|
|
204
224
|
let edge;
|
|
205
225
|
this._commit('quick-add', () => {
|
|
206
|
-
created = createNode(type, Math.round(x), Math.round(y), preset);
|
|
226
|
+
created = createNode(type, Math.round(x), Math.round(y), preset, { i18n: this.i18n });
|
|
207
227
|
this.model.nodes.push(created);
|
|
208
228
|
edge = createEdge(sourceId, created.id, {
|
|
209
|
-
name: sourceDef.kind === 'gateway' ?
|
|
229
|
+
name: sourceDef.kind === 'gateway' ? this.i18n.t('modeling.branchName', { index: outgoingCount + 1 }) : '',
|
|
210
230
|
});
|
|
211
231
|
this.model.edges.push(edge);
|
|
212
232
|
});
|
|
@@ -454,7 +474,7 @@ export class BpmnDesigner {
|
|
|
454
474
|
}
|
|
455
475
|
|
|
456
476
|
importXml(xml, engineHint) {
|
|
457
|
-
const model = importBpmn(xml, engineHint);
|
|
477
|
+
const model = importBpmn(xml, engineHint, { i18n: this.i18n });
|
|
458
478
|
this.setModel(model, { resetHistory: true });
|
|
459
479
|
requestAnimationFrame(() => this.renderer.fitReadable(72));
|
|
460
480
|
return model;
|
|
@@ -468,31 +488,32 @@ export class BpmnDesigner {
|
|
|
468
488
|
openSvgExportPreview(options) { return this.renderer.openSvgExportPreview(options); }
|
|
469
489
|
|
|
470
490
|
validate() {
|
|
491
|
+
const t = (key, params) => this.i18n.t(key, params);
|
|
471
492
|
const issues = [];
|
|
472
493
|
const starts = this.model.nodes.filter((n) => NODE_DEFINITIONS[n.type]?.eventStage === 'start');
|
|
473
494
|
const ends = this.model.nodes.filter((n) => NODE_DEFINITIONS[n.type]?.eventStage === 'end');
|
|
474
|
-
if (!starts.length) issues.push({ level: 'error', message: '
|
|
475
|
-
if (!ends.length) issues.push({ level: 'warning', message: '
|
|
495
|
+
if (!starts.length) issues.push({ level: 'error', message: t('validation.missingStartEvent') });
|
|
496
|
+
if (!ends.length) issues.push({ level: 'warning', message: t('validation.missingEndEvent') });
|
|
476
497
|
for (const edge of this.model.edges) {
|
|
477
|
-
if (!getNode(this.model, edge.source) || !getNode(this.model, edge.target)) issues.push({ level: 'error', elementId: edge.id, message: '
|
|
478
|
-
if ((edge.type || 'sequenceFlow') === 'sequenceFlow' && edge.source === edge.target) issues.push({ level: 'error', elementId: edge.id, message: '
|
|
498
|
+
if (!getNode(this.model, edge.source) || !getNode(this.model, edge.target)) issues.push({ level: 'error', elementId: edge.id, message: t('validation.edgeMissingNode') });
|
|
499
|
+
if ((edge.type || 'sequenceFlow') === 'sequenceFlow' && edge.source === edge.target) issues.push({ level: 'error', elementId: edge.id, message: t('validation.sequenceFlowSelfLoop') });
|
|
479
500
|
}
|
|
480
501
|
for (const node of this.model.nodes) {
|
|
481
502
|
const def = NODE_DEFINITIONS[node.type] || NODE_DEFINITIONS.generic;
|
|
482
|
-
if (node.type === 'serviceTask' && !node.properties?.implementation) issues.push({ level: 'warning', elementId: node.id, message:
|
|
483
|
-
if (node.type === 'userTask' && !node.properties?.assignee && !node.properties?.candidateUsers && !node.properties?.candidateGroups) issues.push({ level: 'warning', elementId: node.id, message:
|
|
503
|
+
if (node.type === 'serviceTask' && !node.properties?.implementation) issues.push({ level: 'warning', elementId: node.id, message: t('validation.serviceTaskMissingImpl', { name: node.name }) });
|
|
504
|
+
if (node.type === 'userTask' && !node.properties?.assignee && !node.properties?.candidateUsers && !node.properties?.candidateGroups) issues.push({ level: 'warning', elementId: node.id, message: t('validation.userTaskMissingAssignee', { name: node.name }) });
|
|
484
505
|
if (def.kind === 'gateway') {
|
|
485
506
|
const outgoing = this.model.edges.filter((e) => e.source === node.id && (e.type || 'sequenceFlow') === 'sequenceFlow');
|
|
486
507
|
if (node.type === 'parallelGateway') {
|
|
487
|
-
for (const message of validateParallelGateway(this.model, node)) issues.push({ level: 'warning', elementId: node.id, message:
|
|
488
|
-
} else if (outgoing.length < 2) issues.push({ level: 'warning', elementId: node.id, message:
|
|
508
|
+
for (const message of validateParallelGateway(this.model, node, { i18n: this.i18n })) issues.push({ level: 'warning', elementId: node.id, message: t('validation.nodeIssue', { name: node.name, message }) });
|
|
509
|
+
} else if (outgoing.length < 2) issues.push({ level: 'warning', elementId: node.id, message: t('validation.gatewayNeedsTwoOutgoing', { name: node.name }) });
|
|
489
510
|
if (['exclusiveGateway', 'inclusiveGateway'].includes(node.type)) {
|
|
490
511
|
const unnamed = outgoing.filter((edge) => !edge.name);
|
|
491
|
-
if (outgoing.length >= 2 && unnamed.length) issues.push({ level: 'warning', elementId: node.id, message:
|
|
512
|
+
if (outgoing.length >= 2 && unnamed.length) issues.push({ level: 'warning', elementId: node.id, message: t('validation.gatewayBranchNeedsName', { name: node.name }) });
|
|
492
513
|
}
|
|
493
514
|
}
|
|
494
|
-
if (def.kind === 'boundary' && !node.properties?.attachedToRef) issues.push({ level: 'warning', elementId: node.id, message:
|
|
495
|
-
if (def.eventDefinition === 'timer' && !node.properties?.timerValue) issues.push({ level: 'warning', elementId: node.id, message:
|
|
515
|
+
if (def.kind === 'boundary' && !node.properties?.attachedToRef) issues.push({ level: 'warning', elementId: node.id, message: t('validation.boundaryMissingTarget', { name: node.name }) });
|
|
516
|
+
if (def.eventDefinition === 'timer' && !node.properties?.timerValue) issues.push({ level: 'warning', elementId: node.id, message: t('validation.timerMissingExpression', { name: node.name }) });
|
|
496
517
|
}
|
|
497
518
|
return issues;
|
|
498
519
|
}
|
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
import type { BpmnNode, ProcessModel } from '../core/index.js'
|
|
2
|
+
import type { I18nController, NovaI18nOptions } from '../i18n/index.js'
|
|
2
3
|
import type { IconRegistry, NodeVisualResolution } from '../icons/index.js'
|
|
3
|
-
import type { NodeRuntimePresentation, ProcessInstanceSnapshot, RuntimeApprovalActionPresentation, RuntimePresentation, RuntimeAssetRef } from '../runtime/index.js'
|
|
4
|
+
import type { NodeRuntimePresentation, ProcessInstanceSnapshot, RuntimeApprovalActionPresentation, RuntimePresentation, RuntimeAssetRef, RuntimeTimeField, RuntimeTimeFormatOptions, RuntimeTimeFormatter } from '../runtime/index.js'
|
|
4
5
|
import type { NovaResolvedTheme, NovaThemeSnapshot, RuntimeAppearanceOptions, RuntimeAppearanceResolver, ThemeController } from '../theme/index.js'
|
|
5
6
|
import type { NodeSubtitleResolver } from '../node-presentation/index.js'
|
|
6
7
|
|
|
7
8
|
export type SvgExportTheme = 'current' | NovaResolvedTheme
|
|
8
|
-
export interface SvgExportOptions {
|
|
9
|
+
export interface SvgExportOptions extends NovaI18nOptions {
|
|
9
10
|
theme?: SvgExportTheme
|
|
10
11
|
transparentBackground?: boolean
|
|
11
12
|
padding?: number
|
|
12
13
|
filename?: string
|
|
13
14
|
title?: string
|
|
14
15
|
signal?: AbortSignal
|
|
16
|
+
formatRuntimeTime?: RuntimeTimeFormatter | null
|
|
17
|
+
runtimeTimeFormat?: RuntimeTimeFormatOptions | null
|
|
15
18
|
}
|
|
16
19
|
export interface SvgExportWarning {
|
|
17
20
|
code: string
|
|
@@ -49,10 +52,12 @@ export type RuntimeTimelineSvgRenderer = (context: {
|
|
|
49
52
|
themeSnapshot: NovaThemeSnapshot
|
|
50
53
|
appearance: RuntimeAppearanceResolver
|
|
51
54
|
resolveAsset?: SvgRuntimeAssetResolver
|
|
55
|
+
formatTime?: (value?: string | null, field?: RuntimeTimeField) => string
|
|
56
|
+
i18n?: I18nController
|
|
52
57
|
signal?: AbortSignal
|
|
53
58
|
}) => void | { height?: number } | Promise<void | { height?: number }>
|
|
54
59
|
export type SvgRuntimeAssetResolver = (asset: RuntimeAssetRef, purpose: 'export', action: RuntimeApprovalActionPresentation) => string | null | Promise<string | null>
|
|
55
|
-
export interface DiagramSvgExportContext {
|
|
60
|
+
export interface DiagramSvgExportContext extends NovaI18nOptions {
|
|
56
61
|
document?: Document
|
|
57
62
|
root?: HTMLElement
|
|
58
63
|
model: ProcessModel
|
|
@@ -70,7 +75,7 @@ export interface DiagramSvgExportContext {
|
|
|
70
75
|
mode?: 'design' | 'viewer' | 'instance'
|
|
71
76
|
label?: string
|
|
72
77
|
}
|
|
73
|
-
export interface RuntimeTimelineSvgExportContext {
|
|
78
|
+
export interface RuntimeTimelineSvgExportContext extends NovaI18nOptions {
|
|
74
79
|
document?: Document
|
|
75
80
|
root?: HTMLElement
|
|
76
81
|
model: ProcessModel
|
|
@@ -85,6 +90,8 @@ export interface RuntimeTimelineSvgExportContext {
|
|
|
85
90
|
resolveAsset?: SvgRuntimeAssetResolver
|
|
86
91
|
assetCache?: Map<string, string>
|
|
87
92
|
timelineRenderer?: RuntimeTimelineSvgRenderer
|
|
93
|
+
formatRuntimeTime?: RuntimeTimeFormatter | null
|
|
94
|
+
runtimeTimeFormat?: RuntimeTimeFormatOptions | null
|
|
88
95
|
label?: string
|
|
89
96
|
}
|
|
90
97
|
export function sanitizeSvgFilename(value: string, fallback?: string): string
|
|
@@ -92,7 +99,7 @@ export function exportDiagramSvg(context: DiagramSvgExportContext, options?: Svg
|
|
|
92
99
|
export function exportRuntimeTimelineSvg(context: RuntimeTimelineSvgExportContext, options?: SvgExportOptions & { width?: number; description?: string }): Promise<SvgExportArtifact>
|
|
93
100
|
export function downloadSvg(artifact: SvgExportArtifact, options?: { document?: Document }): string
|
|
94
101
|
|
|
95
|
-
export interface SvgExportPreviewOptions {
|
|
102
|
+
export interface SvgExportPreviewOptions extends NovaI18nOptions {
|
|
96
103
|
container: HTMLElement
|
|
97
104
|
createArtifact(options: SvgExportOptions): Promise<SvgExportArtifact>
|
|
98
105
|
title?: string
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { resolveI18n } from '../i18n/index.js';
|
|
1
2
|
import { downloadSvg } from './render.js';
|
|
2
3
|
|
|
3
4
|
function element(document, tag, className = '', text = '') {
|
|
@@ -18,12 +19,13 @@ function clamp(value, min, max) {
|
|
|
18
19
|
}
|
|
19
20
|
|
|
20
21
|
export class SvgExportPreviewController {
|
|
21
|
-
constructor({ container, createArtifact, title
|
|
22
|
+
constructor({ container, createArtifact, title, initialTheme = 'current', onClose = null, onDownload = null, i18n = null, locale, messages } = {}) {
|
|
22
23
|
if (!container) throw new Error('SVG export preview requires a container.');
|
|
23
24
|
if (typeof createArtifact !== 'function') throw new Error('SVG export preview requires createArtifact().');
|
|
24
25
|
this.container = container;
|
|
25
26
|
this.document = container.ownerDocument;
|
|
26
27
|
this.ownerWindow = this.document.defaultView || globalThis;
|
|
28
|
+
this.i18n = resolveI18n({ i18n, locale, messages });
|
|
27
29
|
this.createArtifact = createArtifact;
|
|
28
30
|
this.onClose = onClose;
|
|
29
31
|
this.onDownload = onDownload;
|
|
@@ -37,11 +39,15 @@ export class SvgExportPreviewController {
|
|
|
37
39
|
this.drag = null;
|
|
38
40
|
this.closed = false;
|
|
39
41
|
this._restoreFocus = this.document.activeElement instanceof this.ownerWindow.HTMLElement ? this.document.activeElement : null;
|
|
40
|
-
this._build(title);
|
|
42
|
+
this._build(title || this.i18n.t('exportSvg.preview.defaultTitle'));
|
|
41
43
|
this._bind();
|
|
42
44
|
this._generate();
|
|
43
45
|
}
|
|
44
46
|
|
|
47
|
+
_t(key, params) {
|
|
48
|
+
return this.i18n.t(key, params);
|
|
49
|
+
}
|
|
50
|
+
|
|
45
51
|
_build(title) {
|
|
46
52
|
const document = this.document;
|
|
47
53
|
const root = element(document, 'div', 'nova-svg-export-preview is-entering');
|
|
@@ -51,17 +57,21 @@ export class SvgExportPreviewController {
|
|
|
51
57
|
const dialog = element(document, 'section', 'nova-svg-export-dialog');
|
|
52
58
|
const header = element(document, 'header', 'nova-svg-export-header');
|
|
53
59
|
const heading = element(document, 'div', 'nova-svg-export-heading');
|
|
54
|
-
heading.append(element(document, 'strong', '', title), element(document, 'span', '', '
|
|
60
|
+
heading.append(element(document, 'strong', '', title), element(document, 'span', '', this._t('exportSvg.preview.subtitle')));
|
|
55
61
|
const close = button(document, '×', 'nova-svg-export-close');
|
|
56
|
-
close.setAttribute('aria-label', '
|
|
62
|
+
close.setAttribute('aria-label', this._t('exportSvg.preview.closeAria'));
|
|
57
63
|
header.append(heading, close);
|
|
58
64
|
|
|
59
65
|
const toolbar = element(document, 'div', 'nova-svg-export-toolbar');
|
|
60
66
|
const themeGroup = element(document, 'div', 'nova-svg-export-theme');
|
|
61
67
|
themeGroup.setAttribute('role', 'group');
|
|
62
|
-
themeGroup.setAttribute('aria-label', '
|
|
68
|
+
themeGroup.setAttribute('aria-label', this._t('exportSvg.preview.themeGroupAria'));
|
|
63
69
|
this.themeButtons = new Map();
|
|
64
|
-
for (const option of [
|
|
70
|
+
for (const option of [
|
|
71
|
+
{ value: 'current', label: this._t('exportSvg.preview.themeCurrent') },
|
|
72
|
+
{ value: 'light', label: this._t('exportSvg.preview.themeLight') },
|
|
73
|
+
{ value: 'dark', label: this._t('exportSvg.preview.themeDark') },
|
|
74
|
+
]) {
|
|
65
75
|
const item = button(document, option.label);
|
|
66
76
|
item.dataset.exportTheme = option.value;
|
|
67
77
|
item.addEventListener('click', () => this.setTheme(option.value));
|
|
@@ -72,14 +82,14 @@ export class SvgExportPreviewController {
|
|
|
72
82
|
const transparent = element(document, 'input');
|
|
73
83
|
transparent.type = 'checkbox';
|
|
74
84
|
transparent.addEventListener('change', () => this.setTransparentBackground(transparent.checked));
|
|
75
|
-
transparentLabel.append(transparent, document.createTextNode('
|
|
85
|
+
transparentLabel.append(transparent, document.createTextNode(this._t('exportSvg.preview.transparentBackground')));
|
|
76
86
|
const viewportTools = element(document, 'div', 'nova-svg-export-viewport-tools');
|
|
77
87
|
const zoomOut = button(document, '−');
|
|
78
|
-
zoomOut.title = '
|
|
79
|
-
const fit = button(document, '
|
|
80
|
-
const actual = button(document, '
|
|
88
|
+
zoomOut.title = this._t('exportSvg.preview.zoomOut');
|
|
89
|
+
const fit = button(document, this._t('exportSvg.preview.fitView'));
|
|
90
|
+
const actual = button(document, this._t('exportSvg.preview.actualSize'));
|
|
81
91
|
const zoomIn = button(document, '+');
|
|
82
|
-
zoomIn.title = '
|
|
92
|
+
zoomIn.title = this._t('exportSvg.preview.zoomIn');
|
|
83
93
|
this.zoomText = element(document, 'span', '', '100%');
|
|
84
94
|
viewportTools.append(zoomOut, this.zoomText, zoomIn, fit, actual);
|
|
85
95
|
toolbar.append(themeGroup, transparentLabel, viewportTools);
|
|
@@ -87,25 +97,25 @@ export class SvgExportPreviewController {
|
|
|
87
97
|
const body = element(document, 'div', 'nova-svg-export-body');
|
|
88
98
|
const viewport = element(document, 'div', 'nova-svg-export-viewport');
|
|
89
99
|
viewport.tabIndex = 0;
|
|
90
|
-
viewport.setAttribute('aria-label', '
|
|
100
|
+
viewport.setAttribute('aria-label', this._t('exportSvg.preview.viewportAria'));
|
|
91
101
|
const stage = element(document, 'div', 'nova-svg-export-stage');
|
|
92
102
|
const image = element(document, 'img', 'nova-svg-export-image');
|
|
93
|
-
image.alt = '
|
|
103
|
+
image.alt = this._t('exportSvg.preview.imageAlt');
|
|
94
104
|
stage.appendChild(image);
|
|
95
105
|
viewport.appendChild(stage);
|
|
96
106
|
const state = element(document, 'div', 'nova-svg-export-state');
|
|
97
|
-
state.append(element(document, 'span', 'nova-svg-export-spinner'), element(document, 'strong', '', '
|
|
107
|
+
state.append(element(document, 'span', 'nova-svg-export-spinner'), element(document, 'strong', '', this._t('exportSvg.preview.generating')));
|
|
98
108
|
body.append(viewport, state);
|
|
99
109
|
|
|
100
110
|
const warning = element(document, 'div', 'nova-svg-export-warnings');
|
|
101
111
|
warning.hidden = true;
|
|
102
112
|
const footer = element(document, 'footer', 'nova-svg-export-footer');
|
|
103
|
-
const summary = element(document, 'span', 'nova-svg-export-summary', '
|
|
113
|
+
const summary = element(document, 'span', 'nova-svg-export-summary', this._t('exportSvg.preview.preparingExport'));
|
|
104
114
|
const actions = element(document, 'div', 'nova-svg-export-actions');
|
|
105
|
-
const cancel = button(document, '
|
|
106
|
-
const retry = button(document, '
|
|
115
|
+
const cancel = button(document, this._t('exportSvg.preview.cancel'));
|
|
116
|
+
const retry = button(document, this._t('exportSvg.preview.retry'), 'nova-svg-export-retry');
|
|
107
117
|
retry.hidden = true;
|
|
108
|
-
const confirm = button(document, '
|
|
118
|
+
const confirm = button(document, this._t('exportSvg.preview.confirmDownload'), 'is-primary');
|
|
109
119
|
confirm.disabled = true;
|
|
110
120
|
actions.append(cancel, retry, confirm);
|
|
111
121
|
footer.append(summary, actions);
|
|
@@ -200,8 +210,8 @@ export class SvgExportPreviewController {
|
|
|
200
210
|
this.root.classList.add('is-loading');
|
|
201
211
|
this.state.hidden = false;
|
|
202
212
|
this.state.classList.remove('is-error');
|
|
203
|
-
this.state.querySelector('strong').textContent = '
|
|
204
|
-
this.summary.textContent = '
|
|
213
|
+
this.state.querySelector('strong').textContent = this._t('exportSvg.preview.generating');
|
|
214
|
+
this.summary.textContent = this._t('exportSvg.preview.preparingFullContent');
|
|
205
215
|
this._revokePreviewUrl();
|
|
206
216
|
this.image.removeAttribute('src');
|
|
207
217
|
try {
|
|
@@ -224,8 +234,8 @@ export class SvgExportPreviewController {
|
|
|
224
234
|
this.root.classList.remove('is-loading');
|
|
225
235
|
this.state.hidden = false;
|
|
226
236
|
this.state.classList.add('is-error');
|
|
227
|
-
this.state.querySelector('strong').textContent =
|
|
228
|
-
this.summary.textContent = '
|
|
237
|
+
this.state.querySelector('strong').textContent = this._t('exportSvg.preview.failed', { message: error?.message || this._t('exportSvg.preview.unknownError') });
|
|
238
|
+
this.summary.textContent = this._t('exportSvg.preview.notGenerated');
|
|
229
239
|
this.retryButton.hidden = false;
|
|
230
240
|
}
|
|
231
241
|
}
|
|
@@ -234,10 +244,10 @@ export class SvgExportPreviewController {
|
|
|
234
244
|
this.warning.replaceChildren();
|
|
235
245
|
if (!warnings.length) { this.warning.hidden = true; return; }
|
|
236
246
|
this.warning.hidden = false;
|
|
237
|
-
this.warning.appendChild(element(this.document, 'strong', '',
|
|
247
|
+
this.warning.appendChild(element(this.document, 'strong', '', this._t('exportSvg.preview.warningsHeading', { count: warnings.length })));
|
|
238
248
|
const list = element(this.document, 'ul');
|
|
239
249
|
warnings.slice(0, 5).forEach((item) => list.appendChild(element(this.document, 'li', '', item.message)));
|
|
240
|
-
if (warnings.length > 5) list.appendChild(element(this.document, 'li', '',
|
|
250
|
+
if (warnings.length > 5) list.appendChild(element(this.document, 'li', '', this._t('exportSvg.preview.warningsMore', { count: warnings.length - 5 })));
|
|
241
251
|
this.warning.appendChild(list);
|
|
242
252
|
}
|
|
243
253
|
|