@drawback/ui 0.0.0-stage → 0.1.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 +22 -2
- package/dist/i18n-BZnCrD-C.d.mts +265 -0
- package/dist/index.d.mts +588 -0
- package/dist/index.mjs +4821 -0
- package/dist/locales/de.d.mts +3 -0
- package/dist/locales/de.mjs +231 -0
- package/package.json +69 -4
- package/src/app/default-editor.tsx +371 -0
- package/src/components/color-picker/color-picker.tsx +341 -0
- package/src/components/color-picker/colors.ts +135 -0
- package/src/components/font-picker/font-picker.tsx +298 -0
- package/src/components/icons.tsx +222 -0
- package/src/components/primitives.tsx +565 -0
- package/src/components/style-icons.tsx +172 -0
- package/src/features/canvas-commands/canvas-commands.tsx +173 -0
- package/src/features/context-menu/context-menu.tsx +354 -0
- package/src/features/controls/controls.tsx +281 -0
- package/src/features/export/export-dialog.tsx +164 -0
- package/src/features/layers/layers-tree.ts +335 -0
- package/src/features/layers/layers.tsx +858 -0
- package/src/features/links/links.tsx +268 -0
- package/src/features/main-menu/canvas-properties.tsx +121 -0
- package/src/features/main-menu/main-menu.tsx +215 -0
- package/src/features/minimap/minimap.tsx +69 -0
- package/src/features/properties/linear-properties.tsx +169 -0
- package/src/features/properties/properties.tsx +573 -0
- package/src/features/shortcuts/shortcuts-dialog.tsx +120 -0
- package/src/features/toolbar/toolbar.tsx +216 -0
- package/src/hooks/use-latest.ts +16 -0
- package/src/index.ts +138 -0
- package/src/lib/commands.ts +14 -0
- package/src/lib/download.ts +8 -0
- package/src/lib/i18n.ts +350 -0
- package/src/lib/locales/de.ts +231 -0
- package/src/lib/plugins.tsx +92 -0
- package/src/lib/registry.ts +140 -0
- package/src/stores/ui-context.tsx +253 -0
- package/src/styles.css +1366 -0
package/src/lib/i18n.ts
ADDED
|
@@ -0,0 +1,350 @@
|
|
|
1
|
+
export const en = {
|
|
2
|
+
'toolbar.label': 'Drawing tools',
|
|
3
|
+
'toolbar.lock': 'Keep selected tool active after drawing',
|
|
4
|
+
'toolbar.more': 'More tools',
|
|
5
|
+
'tool.core.select': 'Selection',
|
|
6
|
+
'tool.core.hand': 'Hand (panning)',
|
|
7
|
+
'tool.core.rectangle': 'Rectangle',
|
|
8
|
+
'tool.core.diamond': 'Diamond',
|
|
9
|
+
'tool.core.ellipse': 'Ellipse',
|
|
10
|
+
'tool.core.arrow': 'Arrow',
|
|
11
|
+
'tool.core.line': 'Line',
|
|
12
|
+
'tool.core.freedraw': 'Draw',
|
|
13
|
+
'tool.core.text': 'Text',
|
|
14
|
+
'tool.core.image': 'Insert image',
|
|
15
|
+
'tool.core.eraser': 'Eraser',
|
|
16
|
+
'tool.core.laser': 'Laser pointer',
|
|
17
|
+
'tool.core.frame': 'Frame tool',
|
|
18
|
+
'shortcut.hint': '{label} — {shortcut}',
|
|
19
|
+
/** Joins alternative shortcuts in tooltips: "R or 2". */
|
|
20
|
+
'shortcut.or': ' or ',
|
|
21
|
+
'history.undo': 'Undo',
|
|
22
|
+
'history.redo': 'Redo',
|
|
23
|
+
'zoom.in': 'Zoom in',
|
|
24
|
+
'zoom.out': 'Zoom out',
|
|
25
|
+
'zoom.reset': 'Reset zoom',
|
|
26
|
+
'zoom.fit': 'Zoom to fit',
|
|
27
|
+
'zoom.toSelection': 'Zoom to selection',
|
|
28
|
+
'zoom.menu': 'Zoom',
|
|
29
|
+
'zoom.level': '{percent}%',
|
|
30
|
+
'scroll.toContent': 'Scroll back to content',
|
|
31
|
+
'zen.enter': 'Zen mode',
|
|
32
|
+
'zen.exit': 'Exit zen mode',
|
|
33
|
+
'view.exit': 'Exit view mode',
|
|
34
|
+
'laser.label': 'Laser pointer',
|
|
35
|
+
'properties.label': 'Element properties',
|
|
36
|
+
'properties.stroke': 'Stroke',
|
|
37
|
+
'properties.background': 'Background',
|
|
38
|
+
'properties.fill': 'Fill',
|
|
39
|
+
'properties.strokeWidth': 'Stroke width',
|
|
40
|
+
'properties.strokeStyle': 'Stroke style',
|
|
41
|
+
'properties.sloppiness': 'Sloppiness',
|
|
42
|
+
'properties.arrowType': 'Arrow type',
|
|
43
|
+
'properties.polygon': 'Polygon',
|
|
44
|
+
'properties.cornerRadius': 'Edges',
|
|
45
|
+
'properties.opacity': 'Opacity',
|
|
46
|
+
'properties.arrowheads': 'Arrowheads',
|
|
47
|
+
'properties.startArrowhead': 'Start',
|
|
48
|
+
'properties.endArrowhead': 'End',
|
|
49
|
+
'properties.fontFamily': 'Font family',
|
|
50
|
+
'properties.fontSize': 'Font size',
|
|
51
|
+
'properties.textAlign': 'Text align',
|
|
52
|
+
'properties.textColor': 'Text color',
|
|
53
|
+
'properties.layers': 'Layers',
|
|
54
|
+
'properties.align': 'Align',
|
|
55
|
+
'properties.actions': 'Actions',
|
|
56
|
+
'properties.mixed': 'Mixed',
|
|
57
|
+
'properties.custom': 'Color',
|
|
58
|
+
'properties.selected': '{count, plural, one {# element} other {# elements}} selected',
|
|
59
|
+
'value.none': 'None',
|
|
60
|
+
'value.solid': 'Solid',
|
|
61
|
+
'value.hachure': 'Hatch',
|
|
62
|
+
'value.cross-hatch': 'Cross-hatch',
|
|
63
|
+
'value.dashed': 'Dashed',
|
|
64
|
+
'value.dotted': 'Dotted',
|
|
65
|
+
'value.thin': 'Thin',
|
|
66
|
+
'value.bold': 'Bold',
|
|
67
|
+
'value.extraBold': 'Extra bold',
|
|
68
|
+
'value.architect': 'Architect',
|
|
69
|
+
'value.artist': 'Artist',
|
|
70
|
+
'value.cartoonist': 'Cartoonist',
|
|
71
|
+
'value.sharp': 'Sharp',
|
|
72
|
+
'value.curved': 'Curved',
|
|
73
|
+
'value.elbow': 'Elbow',
|
|
74
|
+
'value.open': 'Open',
|
|
75
|
+
'value.closed': 'Closed',
|
|
76
|
+
'value.round': 'Round',
|
|
77
|
+
'value.small': 'Small',
|
|
78
|
+
'value.medium': 'Medium',
|
|
79
|
+
'value.large': 'Large',
|
|
80
|
+
'value.extraLarge': 'Extra large',
|
|
81
|
+
'value.left': 'Left',
|
|
82
|
+
'value.center': 'Center',
|
|
83
|
+
'value.right': 'Right',
|
|
84
|
+
'value.arrow': 'Arrow',
|
|
85
|
+
'value.triangle': 'Triangle',
|
|
86
|
+
'value.bar': 'Bar',
|
|
87
|
+
'value.circle': 'Circle',
|
|
88
|
+
'value.diamond': 'Diamond',
|
|
89
|
+
'font.core.sans': 'Normal',
|
|
90
|
+
'font.core.hand': 'Hand-drawn',
|
|
91
|
+
'font.core.mono': 'Code',
|
|
92
|
+
'font.more': 'More fonts',
|
|
93
|
+
'font.current': 'Font: {name}',
|
|
94
|
+
'font.search': 'Quick search',
|
|
95
|
+
'font.inScene': 'In this scene',
|
|
96
|
+
'font.available': 'Available fonts',
|
|
97
|
+
'font.none': 'No fonts found',
|
|
98
|
+
'action.bringToFront': 'Bring to front',
|
|
99
|
+
'action.bringForward': 'Bring forward',
|
|
100
|
+
'action.sendBackward': 'Send backward',
|
|
101
|
+
'action.sendToBack': 'Send to back',
|
|
102
|
+
'action.alignLeft': 'Align left',
|
|
103
|
+
'action.alignCenter': 'Center horizontally',
|
|
104
|
+
'action.alignRight': 'Align right',
|
|
105
|
+
'action.alignTop': 'Align top',
|
|
106
|
+
'action.alignMiddle': 'Center vertically',
|
|
107
|
+
'action.alignBottom': 'Align bottom',
|
|
108
|
+
'action.distributeHorizontal': 'Distribute horizontally',
|
|
109
|
+
'action.distributeVertical': 'Distribute vertically',
|
|
110
|
+
'action.group': 'Group selection',
|
|
111
|
+
'action.ungroup': 'Ungroup',
|
|
112
|
+
'action.flipHorizontal': 'Flip horizontal',
|
|
113
|
+
'action.flipVertical': 'Flip vertical',
|
|
114
|
+
'action.lock': 'Lock or unlock',
|
|
115
|
+
'action.duplicate': 'Duplicate',
|
|
116
|
+
'action.delete': 'Delete',
|
|
117
|
+
'action.crop': 'Crop image',
|
|
118
|
+
'action.copy': 'Copy',
|
|
119
|
+
'action.cut': 'Cut',
|
|
120
|
+
'action.paste': 'Paste',
|
|
121
|
+
'action.selectAll': 'Select all',
|
|
122
|
+
'action.copyStyles': 'Copy styles',
|
|
123
|
+
'action.pasteStyles': 'Paste styles',
|
|
124
|
+
'action.copyAsPng': 'Copy to clipboard as PNG',
|
|
125
|
+
'action.copyAsSvg': 'Copy to clipboard as SVG',
|
|
126
|
+
'action.copyElementLink': 'Copy link to object',
|
|
127
|
+
'toast.linkCopied': 'Link copied',
|
|
128
|
+
'color.open': '{label}: more colors',
|
|
129
|
+
'color.colors': 'Colors',
|
|
130
|
+
'color.shades': 'Shades',
|
|
131
|
+
'color.shade': 'Shade {index}',
|
|
132
|
+
'color.noShades': 'No shades available for this color',
|
|
133
|
+
'color.hex': 'Hex code',
|
|
134
|
+
'color.picker': 'Pick a color from the screen',
|
|
135
|
+
'color.name.transparent': 'Transparent',
|
|
136
|
+
'color.name.white': 'White',
|
|
137
|
+
'color.name.black': 'Black',
|
|
138
|
+
'color.name.gray': 'Gray',
|
|
139
|
+
'color.name.bronze': 'Bronze',
|
|
140
|
+
'color.name.cyan': 'Cyan',
|
|
141
|
+
'color.name.blue': 'Blue',
|
|
142
|
+
'color.name.violet': 'Violet',
|
|
143
|
+
'color.name.grape': 'Grape',
|
|
144
|
+
'color.name.pink': 'Pink',
|
|
145
|
+
'color.name.green': 'Green',
|
|
146
|
+
'color.name.teal': 'Teal',
|
|
147
|
+
'color.name.yellow': 'Yellow',
|
|
148
|
+
'color.name.orange': 'Orange',
|
|
149
|
+
'color.name.red': 'Red',
|
|
150
|
+
'action.canvasProperties': 'Canvas properties',
|
|
151
|
+
'view.mode': 'View mode',
|
|
152
|
+
'bindings.toggle': 'Arrow binding',
|
|
153
|
+
'snapping.midpoints': 'Snap to midpoints',
|
|
154
|
+
'canvas.label': 'Canvas',
|
|
155
|
+
'canvas.background': 'Canvas background',
|
|
156
|
+
'canvas.backgroundReset': 'Use theme background',
|
|
157
|
+
'grid.label': 'Grid',
|
|
158
|
+
'grid.type': 'Grid type',
|
|
159
|
+
'grid.type.none': 'None',
|
|
160
|
+
'grid.type.square': 'Square',
|
|
161
|
+
'grid.type.dot': 'Dots',
|
|
162
|
+
'grid.type.hex-pointy': 'Hex (pointy)',
|
|
163
|
+
'grid.type.hex-flat': 'Hex (flat)',
|
|
164
|
+
'grid.size': 'Cell size',
|
|
165
|
+
'grid.color': 'Grid color',
|
|
166
|
+
'grid.majorEvery': 'Major lines every',
|
|
167
|
+
'grid.visible': 'Show grid',
|
|
168
|
+
'grid.toggle': 'Toggle grid',
|
|
169
|
+
'snapping.label': 'Snapping',
|
|
170
|
+
'snapping.enabled': 'Snap to objects',
|
|
171
|
+
'snapping.grid': 'Snap to grid',
|
|
172
|
+
'theme.label': 'Theme',
|
|
173
|
+
'theme.light': 'Light',
|
|
174
|
+
'theme.dark': 'Dark',
|
|
175
|
+
'theme.system': 'System',
|
|
176
|
+
'language.label': 'Language',
|
|
177
|
+
'layers.label': 'Layers and objects',
|
|
178
|
+
'layers.toggle': 'Layers',
|
|
179
|
+
'layers.search': 'Search',
|
|
180
|
+
'layers.add': 'Add layer',
|
|
181
|
+
'layers.newName': 'Layer {number}',
|
|
182
|
+
'layers.show': 'Show',
|
|
183
|
+
'layers.hide': 'Hide',
|
|
184
|
+
'layers.lock': 'Lock',
|
|
185
|
+
'layers.unlock': 'Unlock',
|
|
186
|
+
'layers.expand': 'Expand',
|
|
187
|
+
'layers.collapse': 'Collapse',
|
|
188
|
+
'layers.rename': 'Rename',
|
|
189
|
+
'layers.delete': 'Delete layer',
|
|
190
|
+
'layers.group': 'Group',
|
|
191
|
+
'layers.empty': 'Nothing here yet',
|
|
192
|
+
'layers.noMatches': 'No matches',
|
|
193
|
+
'layers.dragCount': '{count, plural, one {# element} other {# elements}}',
|
|
194
|
+
'layers.setActive': 'Draw on this layer',
|
|
195
|
+
'menu.label': 'Main menu',
|
|
196
|
+
'menu.open': 'Open…',
|
|
197
|
+
'menu.save': 'Save to file',
|
|
198
|
+
'menu.exportImage': 'Export image…',
|
|
199
|
+
'menu.exportBundle': 'Save with images',
|
|
200
|
+
'menu.reset': 'Reset the canvas',
|
|
201
|
+
'menu.resetConfirm': 'This will clear the whole canvas. Continue?',
|
|
202
|
+
'menu.shortcuts': 'Keyboard shortcuts',
|
|
203
|
+
'menu.canvas': 'Canvas settings',
|
|
204
|
+
'link.edit': 'Edit link…',
|
|
205
|
+
'link.label': 'Link',
|
|
206
|
+
'link.placeholder': 'Type or paste your link here',
|
|
207
|
+
'link.change': 'Edit link',
|
|
208
|
+
'link.save': 'Save',
|
|
209
|
+
'link.remove': 'Remove link',
|
|
210
|
+
'link.invalid': 'This link cannot be used here.',
|
|
211
|
+
'contextMenu.label': 'Context menu',
|
|
212
|
+
'export.title': 'Export image',
|
|
213
|
+
'export.format': 'Format',
|
|
214
|
+
'export.selectionOnly': 'Only selected',
|
|
215
|
+
'export.background': 'Background',
|
|
216
|
+
'export.grid': 'Include grid',
|
|
217
|
+
'export.scale': 'Scale',
|
|
218
|
+
'export.padding': 'Padding',
|
|
219
|
+
'export.download': 'Download',
|
|
220
|
+
'export.warnings': '{count, plural, one {# warning} other {# warnings}}',
|
|
221
|
+
'shortcuts.title': 'Keyboard shortcuts',
|
|
222
|
+
'shortcuts.search': 'Search shortcuts',
|
|
223
|
+
'shortcuts.tools': 'Tools',
|
|
224
|
+
'shortcuts.commands': 'Editor',
|
|
225
|
+
'dialog.close': 'Close',
|
|
226
|
+
'minimap.label': 'Minimap',
|
|
227
|
+
'minimap.toggle': 'Toggle minimap',
|
|
228
|
+
'error.import': 'Could not open the file: {message}',
|
|
229
|
+
} as const;
|
|
230
|
+
|
|
231
|
+
export type MessageKey = keyof typeof en;
|
|
232
|
+
|
|
233
|
+
export interface LanguageInfo {
|
|
234
|
+
readonly locale: string;
|
|
235
|
+
/** Name in the language itself, for the language picker. */
|
|
236
|
+
readonly name: string;
|
|
237
|
+
/** Loads the catalog on first use (English is built in and has none). */
|
|
238
|
+
readonly load?: () => Promise<Messages>;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
/**
|
|
242
|
+
* Built-in languages, offered in the main menu's language picker under their own names.
|
|
243
|
+
* Catalogs other than English are separate chunks, loaded when a locale first needs them.
|
|
244
|
+
*/
|
|
245
|
+
export const LANGUAGES: readonly LanguageInfo[] = [
|
|
246
|
+
{ locale: 'en', name: 'English' },
|
|
247
|
+
{
|
|
248
|
+
locale: 'de',
|
|
249
|
+
name: 'Deutsch',
|
|
250
|
+
load: () => import('./locales/de.js').then((module) => module.de),
|
|
251
|
+
},
|
|
252
|
+
];
|
|
253
|
+
|
|
254
|
+
const loadedCatalogs = new Map<string, Messages>();
|
|
255
|
+
const pendingCatalogs = new Map<string, Promise<Messages | undefined>>();
|
|
256
|
+
|
|
257
|
+
function languageOf(locale: string): LanguageInfo | undefined {
|
|
258
|
+
const base = locale.toLowerCase().split('-')[0];
|
|
259
|
+
return LANGUAGES.find((entry) => entry.locale === base);
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
/**
|
|
263
|
+
* Built-in catalog for a locale (`de-AT` falls back to `de`) once it has loaded, else
|
|
264
|
+
* `undefined` (always for English). See {@link loadMessages}.
|
|
265
|
+
*/
|
|
266
|
+
export function builtinMessages(locale: string): Messages | undefined {
|
|
267
|
+
const language = languageOf(locale);
|
|
268
|
+
return language === undefined ? undefined : loadedCatalogs.get(language.locale);
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
/** Whether `locale` has a built-in catalog that is not loaded yet. */
|
|
272
|
+
export function needsMessages(locale: string): boolean {
|
|
273
|
+
const language = languageOf(locale);
|
|
274
|
+
return language?.load !== undefined && !loadedCatalogs.has(language.locale);
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
/**
|
|
278
|
+
* Loads the built-in catalog for `locale` (once; later calls share the result). Await it
|
|
279
|
+
* before mounting to render a non-English editor without first showing English.
|
|
280
|
+
*/
|
|
281
|
+
export function loadMessages(locale: string): Promise<Messages | undefined> {
|
|
282
|
+
const language = languageOf(locale);
|
|
283
|
+
|
|
284
|
+
if (language?.load === undefined) {
|
|
285
|
+
return Promise.resolve(undefined);
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
const cached = loadedCatalogs.get(language.locale);
|
|
289
|
+
|
|
290
|
+
if (cached !== undefined) {
|
|
291
|
+
return Promise.resolve(cached);
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
let pending = pendingCatalogs.get(language.locale);
|
|
295
|
+
|
|
296
|
+
if (pending === undefined) {
|
|
297
|
+
pending = language.load().then(
|
|
298
|
+
(messages) => {
|
|
299
|
+
loadedCatalogs.set(language.locale, messages);
|
|
300
|
+
pendingCatalogs.delete(language.locale);
|
|
301
|
+
return messages;
|
|
302
|
+
},
|
|
303
|
+
(error: unknown) => {
|
|
304
|
+
pendingCatalogs.delete(language.locale);
|
|
305
|
+
throw error;
|
|
306
|
+
},
|
|
307
|
+
);
|
|
308
|
+
pendingCatalogs.set(language.locale, pending);
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
return pending;
|
|
312
|
+
}
|
|
313
|
+
export type Messages = { readonly [Key in MessageKey]?: string } & {
|
|
314
|
+
readonly [key: string]: string | undefined;
|
|
315
|
+
};
|
|
316
|
+
export type TranslateValues = Readonly<Record<string, string | number>>;
|
|
317
|
+
export type Translate = (key: MessageKey | (string & {}), values?: TranslateValues) => string;
|
|
318
|
+
|
|
319
|
+
const PLURAL = /\{(\w+),\s*plural,\s*((?:[^{}]*\{[^{}]*\})+)\s*\}/g;
|
|
320
|
+
const BRANCH = /(=\d+|zero|one|two|few|many|other)\s*\{([^{}]*)\}/g;
|
|
321
|
+
|
|
322
|
+
/**
|
|
323
|
+
* Translator over a message catalog: `{name}` interpolation and
|
|
324
|
+
* `{count, plural, one {…} other {…}}` with `#` for the number (`Intl.PluralRules`).
|
|
325
|
+
*/
|
|
326
|
+
export function createTranslator(messages: Messages = {}, locale = 'en'): Translate {
|
|
327
|
+
const rules = new Intl.PluralRules(locale);
|
|
328
|
+
const numbers = new Intl.NumberFormat(locale);
|
|
329
|
+
return (key, values = {}) => {
|
|
330
|
+
const template = messages[key] ?? (en as Record<string, string>)[key] ?? key;
|
|
331
|
+
const pluralized = template.replace(PLURAL, (_match, name: string, body: string) => {
|
|
332
|
+
const count = Number(values[name] ?? 0);
|
|
333
|
+
const branches = new Map<string, string>();
|
|
334
|
+
|
|
335
|
+
for (const branch of body.matchAll(BRANCH)) {
|
|
336
|
+
branches.set(branch[1] as string, branch[2] as string);
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
const chosen =
|
|
340
|
+
branches.get(`=${count}`) ??
|
|
341
|
+
branches.get(rules.select(count)) ??
|
|
342
|
+
branches.get('other') ??
|
|
343
|
+
'';
|
|
344
|
+
return chosen.replaceAll('#', numbers.format(count));
|
|
345
|
+
});
|
|
346
|
+
return pluralized.replace(/\{(\w+)\}/g, (match, name: string) =>
|
|
347
|
+
values[name] === undefined ? match : String(values[name]),
|
|
348
|
+
);
|
|
349
|
+
};
|
|
350
|
+
}
|
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
import type { MessageKey } from '../i18n.js';
|
|
2
|
+
|
|
3
|
+
/** German catalog; typed against `en` so a missing key fails the build. */
|
|
4
|
+
export const de: { readonly [Key in MessageKey]: string } = {
|
|
5
|
+
'toolbar.label': 'Zeichenwerkzeuge',
|
|
6
|
+
'toolbar.lock': 'Ausgewähltes Werkzeug nach dem Zeichnen aktiv lassen',
|
|
7
|
+
'toolbar.more': 'Weitere Werkzeuge',
|
|
8
|
+
'tool.core.select': 'Auswahl',
|
|
9
|
+
'tool.core.hand': 'Hand (Verschieben)',
|
|
10
|
+
'tool.core.rectangle': 'Rechteck',
|
|
11
|
+
'tool.core.diamond': 'Raute',
|
|
12
|
+
'tool.core.ellipse': 'Ellipse',
|
|
13
|
+
'tool.core.arrow': 'Pfeil',
|
|
14
|
+
'tool.core.line': 'Linie',
|
|
15
|
+
'tool.core.freedraw': 'Zeichnen',
|
|
16
|
+
'tool.core.text': 'Text',
|
|
17
|
+
'tool.core.image': 'Bild einfügen',
|
|
18
|
+
'tool.core.eraser': 'Radierer',
|
|
19
|
+
'tool.core.laser': 'Laserpointer',
|
|
20
|
+
'tool.core.frame': 'Rahmen',
|
|
21
|
+
'shortcut.hint': '{label} — {shortcut}',
|
|
22
|
+
'shortcut.or': ' oder ',
|
|
23
|
+
'history.undo': 'Rückgängig',
|
|
24
|
+
'history.redo': 'Wiederholen',
|
|
25
|
+
'zoom.in': 'Vergrößern',
|
|
26
|
+
'zoom.out': 'Verkleinern',
|
|
27
|
+
'zoom.reset': 'Zoom zurücksetzen',
|
|
28
|
+
'zoom.fit': 'Alles anzeigen',
|
|
29
|
+
'zoom.toSelection': 'Auf Auswahl zoomen',
|
|
30
|
+
'zoom.menu': 'Zoom',
|
|
31
|
+
'zoom.level': '{percent} %',
|
|
32
|
+
'scroll.toContent': 'Zurück zum Inhalt',
|
|
33
|
+
'zen.enter': 'Zen-Modus',
|
|
34
|
+
'zen.exit': 'Zen-Modus beenden',
|
|
35
|
+
'view.exit': 'Ansichtsmodus beenden',
|
|
36
|
+
'laser.label': 'Laserpointer',
|
|
37
|
+
'properties.label': 'Elementeigenschaften',
|
|
38
|
+
'properties.stroke': 'Kontur',
|
|
39
|
+
'properties.background': 'Hintergrund',
|
|
40
|
+
'properties.fill': 'Füllung',
|
|
41
|
+
'properties.strokeWidth': 'Konturstärke',
|
|
42
|
+
'properties.strokeStyle': 'Konturstil',
|
|
43
|
+
'properties.sloppiness': 'Sauberkeit',
|
|
44
|
+
'properties.arrowType': 'Pfeiltyp',
|
|
45
|
+
'properties.polygon': 'Polygon',
|
|
46
|
+
'properties.cornerRadius': 'Ecken',
|
|
47
|
+
'properties.opacity': 'Deckkraft',
|
|
48
|
+
'properties.arrowheads': 'Pfeilspitzen',
|
|
49
|
+
'properties.startArrowhead': 'Anfang',
|
|
50
|
+
'properties.endArrowhead': 'Ende',
|
|
51
|
+
'properties.fontFamily': 'Schriftart',
|
|
52
|
+
'properties.fontSize': 'Schriftgröße',
|
|
53
|
+
'properties.textAlign': 'Textausrichtung',
|
|
54
|
+
'properties.textColor': 'Textfarbe',
|
|
55
|
+
'properties.layers': 'Ebenen',
|
|
56
|
+
'properties.align': 'Ausrichten',
|
|
57
|
+
'properties.actions': 'Aktionen',
|
|
58
|
+
'properties.mixed': 'Gemischt',
|
|
59
|
+
'properties.custom': 'Farbe',
|
|
60
|
+
'properties.selected': '{count, plural, one {# Element} other {# Elemente}} ausgewählt',
|
|
61
|
+
'value.none': 'Keine',
|
|
62
|
+
'value.solid': 'Vollfläche',
|
|
63
|
+
'value.hachure': 'Schraffur',
|
|
64
|
+
'value.cross-hatch': 'Kreuzschraffur',
|
|
65
|
+
'value.dashed': 'Gestrichelt',
|
|
66
|
+
'value.dotted': 'Gepunktet',
|
|
67
|
+
'value.thin': 'Dünn',
|
|
68
|
+
'value.bold': 'Fett',
|
|
69
|
+
'value.extraBold': 'Extra fett',
|
|
70
|
+
'value.architect': 'Architekt',
|
|
71
|
+
'value.artist': 'Künstler',
|
|
72
|
+
'value.cartoonist': 'Zeichner',
|
|
73
|
+
'value.sharp': 'Scharf',
|
|
74
|
+
'value.curved': 'Gebogen',
|
|
75
|
+
'value.elbow': 'Gewinkelt',
|
|
76
|
+
'value.open': 'Offen',
|
|
77
|
+
'value.closed': 'Geschlossen',
|
|
78
|
+
'value.round': 'Rund',
|
|
79
|
+
'value.small': 'Klein',
|
|
80
|
+
'value.medium': 'Mittel',
|
|
81
|
+
'value.large': 'Groß',
|
|
82
|
+
'value.extraLarge': 'Sehr groß',
|
|
83
|
+
'value.left': 'Links',
|
|
84
|
+
'value.center': 'Mitte',
|
|
85
|
+
'value.right': 'Rechts',
|
|
86
|
+
'value.arrow': 'Pfeil',
|
|
87
|
+
'value.triangle': 'Dreieck',
|
|
88
|
+
'value.bar': 'Balken',
|
|
89
|
+
'value.circle': 'Kreis',
|
|
90
|
+
'value.diamond': 'Raute',
|
|
91
|
+
'font.core.sans': 'Normal',
|
|
92
|
+
'font.core.hand': 'Handschrift',
|
|
93
|
+
'font.core.mono': 'Code',
|
|
94
|
+
'font.more': 'Weitere Schriftarten',
|
|
95
|
+
'font.current': 'Schriftart: {name}',
|
|
96
|
+
'font.search': 'Schnellsuche',
|
|
97
|
+
'font.inScene': 'In dieser Szene',
|
|
98
|
+
'font.available': 'Verfügbare Schriftarten',
|
|
99
|
+
'font.none': 'Keine Schriftarten gefunden',
|
|
100
|
+
'action.bringToFront': 'Ganz nach vorne',
|
|
101
|
+
'action.bringForward': 'Eine Ebene nach vorne',
|
|
102
|
+
'action.sendBackward': 'Eine Ebene nach hinten',
|
|
103
|
+
'action.sendToBack': 'Ganz nach hinten',
|
|
104
|
+
'action.alignLeft': 'Links ausrichten',
|
|
105
|
+
'action.alignCenter': 'Horizontal zentrieren',
|
|
106
|
+
'action.alignRight': 'Rechts ausrichten',
|
|
107
|
+
'action.alignTop': 'Oben ausrichten',
|
|
108
|
+
'action.alignMiddle': 'Vertikal zentrieren',
|
|
109
|
+
'action.alignBottom': 'Unten ausrichten',
|
|
110
|
+
'action.distributeHorizontal': 'Horizontal verteilen',
|
|
111
|
+
'action.distributeVertical': 'Vertikal verteilen',
|
|
112
|
+
'action.group': 'Auswahl gruppieren',
|
|
113
|
+
'action.ungroup': 'Gruppierung aufheben',
|
|
114
|
+
'action.flipHorizontal': 'Horizontal spiegeln',
|
|
115
|
+
'action.flipVertical': 'Vertikal spiegeln',
|
|
116
|
+
'action.lock': 'Sperren oder entsperren',
|
|
117
|
+
'action.duplicate': 'Duplizieren',
|
|
118
|
+
'action.delete': 'Löschen',
|
|
119
|
+
'action.crop': 'Bild zuschneiden',
|
|
120
|
+
'action.copy': 'Kopieren',
|
|
121
|
+
'action.cut': 'Ausschneiden',
|
|
122
|
+
'action.paste': 'Einfügen',
|
|
123
|
+
'action.selectAll': 'Alles auswählen',
|
|
124
|
+
'action.copyStyles': 'Stil kopieren',
|
|
125
|
+
'action.pasteStyles': 'Stil einfügen',
|
|
126
|
+
'action.copyAsPng': 'Als PNG in die Zwischenablage kopieren',
|
|
127
|
+
'action.copyAsSvg': 'Als SVG in die Zwischenablage kopieren',
|
|
128
|
+
'action.copyElementLink': 'Link zum Objekt kopieren',
|
|
129
|
+
'toast.linkCopied': 'Link kopiert',
|
|
130
|
+
'color.open': '{label}: weitere Farben',
|
|
131
|
+
'color.colors': 'Farben',
|
|
132
|
+
'color.shades': 'Abstufungen',
|
|
133
|
+
'color.shade': 'Abstufung {index}',
|
|
134
|
+
'color.noShades': 'Für diese Farbe gibt es keine Abstufungen',
|
|
135
|
+
'color.hex': 'Hex-Code',
|
|
136
|
+
'color.picker': 'Farbe vom Bildschirm aufnehmen',
|
|
137
|
+
'color.name.transparent': 'Transparent',
|
|
138
|
+
'color.name.white': 'Weiß',
|
|
139
|
+
'color.name.black': 'Schwarz',
|
|
140
|
+
'color.name.gray': 'Grau',
|
|
141
|
+
'color.name.bronze': 'Bronze',
|
|
142
|
+
'color.name.cyan': 'Cyan',
|
|
143
|
+
'color.name.blue': 'Blau',
|
|
144
|
+
'color.name.violet': 'Violett',
|
|
145
|
+
'color.name.grape': 'Traube',
|
|
146
|
+
'color.name.pink': 'Pink',
|
|
147
|
+
'color.name.green': 'Grün',
|
|
148
|
+
'color.name.teal': 'Blaugrün',
|
|
149
|
+
'color.name.yellow': 'Gelb',
|
|
150
|
+
'color.name.orange': 'Orange',
|
|
151
|
+
'color.name.red': 'Rot',
|
|
152
|
+
'action.canvasProperties': 'Leinwand-Einstellungen',
|
|
153
|
+
'view.mode': 'Ansichtsmodus',
|
|
154
|
+
'bindings.toggle': 'Pfeile verbinden',
|
|
155
|
+
'snapping.midpoints': 'An Mittelpunkten einrasten',
|
|
156
|
+
'canvas.label': 'Leinwand',
|
|
157
|
+
'canvas.background': 'Leinwand-Hintergrund',
|
|
158
|
+
'canvas.backgroundReset': 'Hintergrund des Designs verwenden',
|
|
159
|
+
'grid.label': 'Raster',
|
|
160
|
+
'grid.type': 'Rastertyp',
|
|
161
|
+
'grid.type.none': 'Keins',
|
|
162
|
+
'grid.type.square': 'Quadrate',
|
|
163
|
+
'grid.type.dot': 'Punkte',
|
|
164
|
+
'grid.type.hex-pointy': 'Hex (spitz)',
|
|
165
|
+
'grid.type.hex-flat': 'Hex (flach)',
|
|
166
|
+
'grid.size': 'Zellengröße',
|
|
167
|
+
'grid.color': 'Rasterfarbe',
|
|
168
|
+
'grid.majorEvery': 'Hauptlinien alle',
|
|
169
|
+
'grid.visible': 'Raster anzeigen',
|
|
170
|
+
'grid.toggle': 'Raster ein/aus',
|
|
171
|
+
'snapping.label': 'Einrasten',
|
|
172
|
+
'snapping.enabled': 'An Objekten einrasten',
|
|
173
|
+
'snapping.grid': 'Am Raster einrasten',
|
|
174
|
+
'theme.label': 'Design',
|
|
175
|
+
'theme.light': 'Hell',
|
|
176
|
+
'theme.dark': 'Dunkel',
|
|
177
|
+
'theme.system': 'System',
|
|
178
|
+
'language.label': 'Sprache',
|
|
179
|
+
'layers.label': 'Ebenen und Objekte',
|
|
180
|
+
'layers.toggle': 'Ebenen',
|
|
181
|
+
'layers.search': 'Suchen',
|
|
182
|
+
'layers.add': 'Ebene hinzufügen',
|
|
183
|
+
'layers.newName': 'Ebene {number}',
|
|
184
|
+
'layers.show': 'Einblenden',
|
|
185
|
+
'layers.hide': 'Ausblenden',
|
|
186
|
+
'layers.lock': 'Sperren',
|
|
187
|
+
'layers.unlock': 'Entsperren',
|
|
188
|
+
'layers.expand': 'Aufklappen',
|
|
189
|
+
'layers.collapse': 'Zuklappen',
|
|
190
|
+
'layers.rename': 'Umbenennen',
|
|
191
|
+
'layers.delete': 'Ebene löschen',
|
|
192
|
+
'layers.group': 'Gruppe',
|
|
193
|
+
'layers.empty': 'Noch nichts hier',
|
|
194
|
+
'layers.noMatches': 'Keine Treffer',
|
|
195
|
+
'layers.dragCount': '{count, plural, one {# Element} other {# Elemente}}',
|
|
196
|
+
'layers.setActive': 'Auf dieser Ebene zeichnen',
|
|
197
|
+
'menu.label': 'Hauptmenü',
|
|
198
|
+
'menu.open': 'Öffnen…',
|
|
199
|
+
'menu.save': 'In Datei speichern',
|
|
200
|
+
'menu.exportImage': 'Bild exportieren…',
|
|
201
|
+
'menu.exportBundle': 'Mit Bildern speichern',
|
|
202
|
+
'menu.reset': 'Leinwand zurücksetzen',
|
|
203
|
+
'menu.resetConfirm': 'Die gesamte Leinwand wird geleert. Fortfahren?',
|
|
204
|
+
'menu.shortcuts': 'Tastenkürzel',
|
|
205
|
+
'menu.canvas': 'Leinwand-Einstellungen',
|
|
206
|
+
'link.edit': 'Link bearbeiten…',
|
|
207
|
+
'link.label': 'Link',
|
|
208
|
+
'link.placeholder': 'Link hier eingeben oder einfügen',
|
|
209
|
+
'link.change': 'Link bearbeiten',
|
|
210
|
+
'link.save': 'Speichern',
|
|
211
|
+
'link.remove': 'Link entfernen',
|
|
212
|
+
'link.invalid': 'Dieser Link kann hier nicht verwendet werden.',
|
|
213
|
+
'contextMenu.label': 'Kontextmenü',
|
|
214
|
+
'export.title': 'Bild exportieren',
|
|
215
|
+
'export.format': 'Format',
|
|
216
|
+
'export.selectionOnly': 'Nur Auswahl',
|
|
217
|
+
'export.background': 'Hintergrund',
|
|
218
|
+
'export.grid': 'Raster einbeziehen',
|
|
219
|
+
'export.scale': 'Skalierung',
|
|
220
|
+
'export.padding': 'Abstand',
|
|
221
|
+
'export.download': 'Herunterladen',
|
|
222
|
+
'export.warnings': '{count, plural, one {# Warnung} other {# Warnungen}}',
|
|
223
|
+
'shortcuts.title': 'Tastenkürzel',
|
|
224
|
+
'shortcuts.search': 'Tastenkürzel suchen',
|
|
225
|
+
'shortcuts.tools': 'Werkzeuge',
|
|
226
|
+
'shortcuts.commands': 'Editor',
|
|
227
|
+
'dialog.close': 'Schließen',
|
|
228
|
+
'minimap.label': 'Übersichtskarte',
|
|
229
|
+
'minimap.toggle': 'Übersichtskarte ein/aus',
|
|
230
|
+
'error.import': 'Die Datei konnte nicht geöffnet werden: {message}',
|
|
231
|
+
};
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import type { EditorPlugin } from '@drawback/core';
|
|
2
|
+
import { useEditor } from '@drawback/react';
|
|
3
|
+
import { useEffect, type ComponentType } from 'react';
|
|
4
|
+
import { useUi } from '../stores/ui-context.js';
|
|
5
|
+
import type {
|
|
6
|
+
ContextMenuItem,
|
|
7
|
+
IconComponent,
|
|
8
|
+
PropertyEditorProps,
|
|
9
|
+
ToolbarItem,
|
|
10
|
+
UiRegistry,
|
|
11
|
+
} from './registry.js';
|
|
12
|
+
|
|
13
|
+
/** What a plugin adds to the default UI. */
|
|
14
|
+
export interface UiPluginFacet {
|
|
15
|
+
readonly toolbar?: readonly ToolbarItem[];
|
|
16
|
+
readonly contextMenu?: readonly ContextMenuItem[];
|
|
17
|
+
/** Property editors by element type. */
|
|
18
|
+
readonly propertyEditors?: Readonly<Record<string, ComponentType<PropertyEditorProps>>>;
|
|
19
|
+
/** Icons by id (tool ids, `describe` icons). */
|
|
20
|
+
readonly icons?: Readonly<Record<string, IconComponent>>;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
declare module '@drawback/core' {
|
|
24
|
+
interface PluginFacets {
|
|
25
|
+
/** Installed by the default UI of an editor with this plugin. */
|
|
26
|
+
readonly ui: UiPluginFacet;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function install(registry: UiRegistry, plugin: EditorPlugin): () => void {
|
|
31
|
+
const facet = plugin.ui;
|
|
32
|
+
const undo: (() => void)[] = [];
|
|
33
|
+
|
|
34
|
+
for (const item of facet?.toolbar ?? []) {
|
|
35
|
+
undo.push(registry.toolbar.register(item));
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
for (const item of facet?.contextMenu ?? []) {
|
|
39
|
+
undo.push(registry.contextMenu.register(item));
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
for (const [type, component] of Object.entries(facet?.propertyEditors ?? {})) {
|
|
43
|
+
undo.push(registry.propertyEditors.register(type, component));
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
for (const [id, component] of Object.entries(facet?.icons ?? {})) {
|
|
47
|
+
undo.push(registry.icons.register(id, component));
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return () => undo.forEach((step) => step());
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Installs the `ui` facets of the editor's plugins into the UI registry and follows later
|
|
55
|
+
* installs and uninstalls. `<DefaultEditor>` renders it; custom layouts can render it too.
|
|
56
|
+
*/
|
|
57
|
+
export function UiPlugins(): null {
|
|
58
|
+
const editor = useEditor();
|
|
59
|
+
const { registry } = useUi();
|
|
60
|
+
|
|
61
|
+
// Syncs the registry with an external system (the editor's plugin list).
|
|
62
|
+
useEffect(() => {
|
|
63
|
+
const installed = new Map<string, () => void>();
|
|
64
|
+
|
|
65
|
+
for (const plugin of editor.plugins.list()) {
|
|
66
|
+
installed.set(plugin.id, install(registry, plugin));
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const off = editor.events.on('plugin.change', (event) => {
|
|
70
|
+
installed.get(event.id)?.();
|
|
71
|
+
installed.delete(event.id);
|
|
72
|
+
const plugin =
|
|
73
|
+
event.change === 'install'
|
|
74
|
+
? editor.plugins.list().find((entry) => entry.id === event.id)
|
|
75
|
+
: undefined;
|
|
76
|
+
|
|
77
|
+
if (plugin !== undefined) {
|
|
78
|
+
installed.set(plugin.id, install(registry, plugin));
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
return () => {
|
|
83
|
+
off();
|
|
84
|
+
|
|
85
|
+
for (const undo of installed.values()) {
|
|
86
|
+
undo();
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
}, [editor, registry]);
|
|
90
|
+
|
|
91
|
+
return null;
|
|
92
|
+
}
|