@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/README.md
CHANGED
|
@@ -1,3 +1,23 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @drawback/ui
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The default editor UI for [drawback](https://github.com/johannes-z/drawback): toolbar, style panel, layers, menus, minimap, link editor and dialogs, themable with CSS variables and translatable. Try it at [johannes-z.github.io/drawback](https://johannes-z.github.io/drawback/).
|
|
4
|
+
|
|
5
|
+
```sh
|
|
6
|
+
npm install @drawback/core @drawback/canvas @drawback/react @drawback/ui react react-dom
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
```tsx
|
|
10
|
+
import { createEditor } from '@drawback/core';
|
|
11
|
+
import { DefaultEditor } from '@drawback/ui';
|
|
12
|
+
import '@drawback/ui/styles.css';
|
|
13
|
+
|
|
14
|
+
const editor = createEditor();
|
|
15
|
+
|
|
16
|
+
export function App() {
|
|
17
|
+
return <DefaultEditor editor={editor} />;
|
|
18
|
+
}
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Languages other than English load on demand (`loadMessages('de')`). See the [default UI](https://github.com/johannes-z/drawback/blob/main/docs/guides/default-ui.md), [theming](https://github.com/johannes-z/drawback/blob/main/docs/guides/theming.md) and [localization](https://github.com/johannes-z/drawback/blob/main/docs/guides/i18n.md) guides.
|
|
22
|
+
|
|
23
|
+
Requires React 19.2 or later. MIT licensed.
|
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
declare const en: {
|
|
2
|
+
readonly 'toolbar.label': 'Drawing tools';
|
|
3
|
+
readonly 'toolbar.lock': 'Keep selected tool active after drawing';
|
|
4
|
+
readonly 'toolbar.more': 'More tools';
|
|
5
|
+
readonly 'tool.core.select': 'Selection';
|
|
6
|
+
readonly 'tool.core.hand': 'Hand (panning)';
|
|
7
|
+
readonly 'tool.core.rectangle': 'Rectangle';
|
|
8
|
+
readonly 'tool.core.diamond': 'Diamond';
|
|
9
|
+
readonly 'tool.core.ellipse': 'Ellipse';
|
|
10
|
+
readonly 'tool.core.arrow': 'Arrow';
|
|
11
|
+
readonly 'tool.core.line': 'Line';
|
|
12
|
+
readonly 'tool.core.freedraw': 'Draw';
|
|
13
|
+
readonly 'tool.core.text': 'Text';
|
|
14
|
+
readonly 'tool.core.image': 'Insert image';
|
|
15
|
+
readonly 'tool.core.eraser': 'Eraser';
|
|
16
|
+
readonly 'tool.core.laser': 'Laser pointer';
|
|
17
|
+
readonly 'tool.core.frame': 'Frame tool';
|
|
18
|
+
readonly 'shortcut.hint': '{label} — {shortcut}';
|
|
19
|
+
/** Joins alternative shortcuts in tooltips: "R or 2". */
|
|
20
|
+
readonly 'shortcut.or': ' or ';
|
|
21
|
+
readonly 'history.undo': 'Undo';
|
|
22
|
+
readonly 'history.redo': 'Redo';
|
|
23
|
+
readonly 'zoom.in': 'Zoom in';
|
|
24
|
+
readonly 'zoom.out': 'Zoom out';
|
|
25
|
+
readonly 'zoom.reset': 'Reset zoom';
|
|
26
|
+
readonly 'zoom.fit': 'Zoom to fit';
|
|
27
|
+
readonly 'zoom.toSelection': 'Zoom to selection';
|
|
28
|
+
readonly 'zoom.menu': 'Zoom';
|
|
29
|
+
readonly 'zoom.level': '{percent}%';
|
|
30
|
+
readonly 'scroll.toContent': 'Scroll back to content';
|
|
31
|
+
readonly 'zen.enter': 'Zen mode';
|
|
32
|
+
readonly 'zen.exit': 'Exit zen mode';
|
|
33
|
+
readonly 'view.exit': 'Exit view mode';
|
|
34
|
+
readonly 'laser.label': 'Laser pointer';
|
|
35
|
+
readonly 'properties.label': 'Element properties';
|
|
36
|
+
readonly 'properties.stroke': 'Stroke';
|
|
37
|
+
readonly 'properties.background': 'Background';
|
|
38
|
+
readonly 'properties.fill': 'Fill';
|
|
39
|
+
readonly 'properties.strokeWidth': 'Stroke width';
|
|
40
|
+
readonly 'properties.strokeStyle': 'Stroke style';
|
|
41
|
+
readonly 'properties.sloppiness': 'Sloppiness';
|
|
42
|
+
readonly 'properties.arrowType': 'Arrow type';
|
|
43
|
+
readonly 'properties.polygon': 'Polygon';
|
|
44
|
+
readonly 'properties.cornerRadius': 'Edges';
|
|
45
|
+
readonly 'properties.opacity': 'Opacity';
|
|
46
|
+
readonly 'properties.arrowheads': 'Arrowheads';
|
|
47
|
+
readonly 'properties.startArrowhead': 'Start';
|
|
48
|
+
readonly 'properties.endArrowhead': 'End';
|
|
49
|
+
readonly 'properties.fontFamily': 'Font family';
|
|
50
|
+
readonly 'properties.fontSize': 'Font size';
|
|
51
|
+
readonly 'properties.textAlign': 'Text align';
|
|
52
|
+
readonly 'properties.textColor': 'Text color';
|
|
53
|
+
readonly 'properties.layers': 'Layers';
|
|
54
|
+
readonly 'properties.align': 'Align';
|
|
55
|
+
readonly 'properties.actions': 'Actions';
|
|
56
|
+
readonly 'properties.mixed': 'Mixed';
|
|
57
|
+
readonly 'properties.custom': 'Color';
|
|
58
|
+
readonly 'properties.selected': '{count, plural, one {# element} other {# elements}} selected';
|
|
59
|
+
readonly 'value.none': 'None';
|
|
60
|
+
readonly 'value.solid': 'Solid';
|
|
61
|
+
readonly 'value.hachure': 'Hatch';
|
|
62
|
+
readonly 'value.cross-hatch': 'Cross-hatch';
|
|
63
|
+
readonly 'value.dashed': 'Dashed';
|
|
64
|
+
readonly 'value.dotted': 'Dotted';
|
|
65
|
+
readonly 'value.thin': 'Thin';
|
|
66
|
+
readonly 'value.bold': 'Bold';
|
|
67
|
+
readonly 'value.extraBold': 'Extra bold';
|
|
68
|
+
readonly 'value.architect': 'Architect';
|
|
69
|
+
readonly 'value.artist': 'Artist';
|
|
70
|
+
readonly 'value.cartoonist': 'Cartoonist';
|
|
71
|
+
readonly 'value.sharp': 'Sharp';
|
|
72
|
+
readonly 'value.curved': 'Curved';
|
|
73
|
+
readonly 'value.elbow': 'Elbow';
|
|
74
|
+
readonly 'value.open': 'Open';
|
|
75
|
+
readonly 'value.closed': 'Closed';
|
|
76
|
+
readonly 'value.round': 'Round';
|
|
77
|
+
readonly 'value.small': 'Small';
|
|
78
|
+
readonly 'value.medium': 'Medium';
|
|
79
|
+
readonly 'value.large': 'Large';
|
|
80
|
+
readonly 'value.extraLarge': 'Extra large';
|
|
81
|
+
readonly 'value.left': 'Left';
|
|
82
|
+
readonly 'value.center': 'Center';
|
|
83
|
+
readonly 'value.right': 'Right';
|
|
84
|
+
readonly 'value.arrow': 'Arrow';
|
|
85
|
+
readonly 'value.triangle': 'Triangle';
|
|
86
|
+
readonly 'value.bar': 'Bar';
|
|
87
|
+
readonly 'value.circle': 'Circle';
|
|
88
|
+
readonly 'value.diamond': 'Diamond';
|
|
89
|
+
readonly 'font.core.sans': 'Normal';
|
|
90
|
+
readonly 'font.core.hand': 'Hand-drawn';
|
|
91
|
+
readonly 'font.core.mono': 'Code';
|
|
92
|
+
readonly 'font.more': 'More fonts';
|
|
93
|
+
readonly 'font.current': 'Font: {name}';
|
|
94
|
+
readonly 'font.search': 'Quick search';
|
|
95
|
+
readonly 'font.inScene': 'In this scene';
|
|
96
|
+
readonly 'font.available': 'Available fonts';
|
|
97
|
+
readonly 'font.none': 'No fonts found';
|
|
98
|
+
readonly 'action.bringToFront': 'Bring to front';
|
|
99
|
+
readonly 'action.bringForward': 'Bring forward';
|
|
100
|
+
readonly 'action.sendBackward': 'Send backward';
|
|
101
|
+
readonly 'action.sendToBack': 'Send to back';
|
|
102
|
+
readonly 'action.alignLeft': 'Align left';
|
|
103
|
+
readonly 'action.alignCenter': 'Center horizontally';
|
|
104
|
+
readonly 'action.alignRight': 'Align right';
|
|
105
|
+
readonly 'action.alignTop': 'Align top';
|
|
106
|
+
readonly 'action.alignMiddle': 'Center vertically';
|
|
107
|
+
readonly 'action.alignBottom': 'Align bottom';
|
|
108
|
+
readonly 'action.distributeHorizontal': 'Distribute horizontally';
|
|
109
|
+
readonly 'action.distributeVertical': 'Distribute vertically';
|
|
110
|
+
readonly 'action.group': 'Group selection';
|
|
111
|
+
readonly 'action.ungroup': 'Ungroup';
|
|
112
|
+
readonly 'action.flipHorizontal': 'Flip horizontal';
|
|
113
|
+
readonly 'action.flipVertical': 'Flip vertical';
|
|
114
|
+
readonly 'action.lock': 'Lock or unlock';
|
|
115
|
+
readonly 'action.duplicate': 'Duplicate';
|
|
116
|
+
readonly 'action.delete': 'Delete';
|
|
117
|
+
readonly 'action.crop': 'Crop image';
|
|
118
|
+
readonly 'action.copy': 'Copy';
|
|
119
|
+
readonly 'action.cut': 'Cut';
|
|
120
|
+
readonly 'action.paste': 'Paste';
|
|
121
|
+
readonly 'action.selectAll': 'Select all';
|
|
122
|
+
readonly 'action.copyStyles': 'Copy styles';
|
|
123
|
+
readonly 'action.pasteStyles': 'Paste styles';
|
|
124
|
+
readonly 'action.copyAsPng': 'Copy to clipboard as PNG';
|
|
125
|
+
readonly 'action.copyAsSvg': 'Copy to clipboard as SVG';
|
|
126
|
+
readonly 'action.copyElementLink': 'Copy link to object';
|
|
127
|
+
readonly 'toast.linkCopied': 'Link copied';
|
|
128
|
+
readonly 'color.open': '{label}: more colors';
|
|
129
|
+
readonly 'color.colors': 'Colors';
|
|
130
|
+
readonly 'color.shades': 'Shades';
|
|
131
|
+
readonly 'color.shade': 'Shade {index}';
|
|
132
|
+
readonly 'color.noShades': 'No shades available for this color';
|
|
133
|
+
readonly 'color.hex': 'Hex code';
|
|
134
|
+
readonly 'color.picker': 'Pick a color from the screen';
|
|
135
|
+
readonly 'color.name.transparent': 'Transparent';
|
|
136
|
+
readonly 'color.name.white': 'White';
|
|
137
|
+
readonly 'color.name.black': 'Black';
|
|
138
|
+
readonly 'color.name.gray': 'Gray';
|
|
139
|
+
readonly 'color.name.bronze': 'Bronze';
|
|
140
|
+
readonly 'color.name.cyan': 'Cyan';
|
|
141
|
+
readonly 'color.name.blue': 'Blue';
|
|
142
|
+
readonly 'color.name.violet': 'Violet';
|
|
143
|
+
readonly 'color.name.grape': 'Grape';
|
|
144
|
+
readonly 'color.name.pink': 'Pink';
|
|
145
|
+
readonly 'color.name.green': 'Green';
|
|
146
|
+
readonly 'color.name.teal': 'Teal';
|
|
147
|
+
readonly 'color.name.yellow': 'Yellow';
|
|
148
|
+
readonly 'color.name.orange': 'Orange';
|
|
149
|
+
readonly 'color.name.red': 'Red';
|
|
150
|
+
readonly 'action.canvasProperties': 'Canvas properties';
|
|
151
|
+
readonly 'view.mode': 'View mode';
|
|
152
|
+
readonly 'bindings.toggle': 'Arrow binding';
|
|
153
|
+
readonly 'snapping.midpoints': 'Snap to midpoints';
|
|
154
|
+
readonly 'canvas.label': 'Canvas';
|
|
155
|
+
readonly 'canvas.background': 'Canvas background';
|
|
156
|
+
readonly 'canvas.backgroundReset': 'Use theme background';
|
|
157
|
+
readonly 'grid.label': 'Grid';
|
|
158
|
+
readonly 'grid.type': 'Grid type';
|
|
159
|
+
readonly 'grid.type.none': 'None';
|
|
160
|
+
readonly 'grid.type.square': 'Square';
|
|
161
|
+
readonly 'grid.type.dot': 'Dots';
|
|
162
|
+
readonly 'grid.type.hex-pointy': 'Hex (pointy)';
|
|
163
|
+
readonly 'grid.type.hex-flat': 'Hex (flat)';
|
|
164
|
+
readonly 'grid.size': 'Cell size';
|
|
165
|
+
readonly 'grid.color': 'Grid color';
|
|
166
|
+
readonly 'grid.majorEvery': 'Major lines every';
|
|
167
|
+
readonly 'grid.visible': 'Show grid';
|
|
168
|
+
readonly 'grid.toggle': 'Toggle grid';
|
|
169
|
+
readonly 'snapping.label': 'Snapping';
|
|
170
|
+
readonly 'snapping.enabled': 'Snap to objects';
|
|
171
|
+
readonly 'snapping.grid': 'Snap to grid';
|
|
172
|
+
readonly 'theme.label': 'Theme';
|
|
173
|
+
readonly 'theme.light': 'Light';
|
|
174
|
+
readonly 'theme.dark': 'Dark';
|
|
175
|
+
readonly 'theme.system': 'System';
|
|
176
|
+
readonly 'language.label': 'Language';
|
|
177
|
+
readonly 'layers.label': 'Layers and objects';
|
|
178
|
+
readonly 'layers.toggle': 'Layers';
|
|
179
|
+
readonly 'layers.search': 'Search';
|
|
180
|
+
readonly 'layers.add': 'Add layer';
|
|
181
|
+
readonly 'layers.newName': 'Layer {number}';
|
|
182
|
+
readonly 'layers.show': 'Show';
|
|
183
|
+
readonly 'layers.hide': 'Hide';
|
|
184
|
+
readonly 'layers.lock': 'Lock';
|
|
185
|
+
readonly 'layers.unlock': 'Unlock';
|
|
186
|
+
readonly 'layers.expand': 'Expand';
|
|
187
|
+
readonly 'layers.collapse': 'Collapse';
|
|
188
|
+
readonly 'layers.rename': 'Rename';
|
|
189
|
+
readonly 'layers.delete': 'Delete layer';
|
|
190
|
+
readonly 'layers.group': 'Group';
|
|
191
|
+
readonly 'layers.empty': 'Nothing here yet';
|
|
192
|
+
readonly 'layers.noMatches': 'No matches';
|
|
193
|
+
readonly 'layers.dragCount': '{count, plural, one {# element} other {# elements}}';
|
|
194
|
+
readonly 'layers.setActive': 'Draw on this layer';
|
|
195
|
+
readonly 'menu.label': 'Main menu';
|
|
196
|
+
readonly 'menu.open': 'Open…';
|
|
197
|
+
readonly 'menu.save': 'Save to file';
|
|
198
|
+
readonly 'menu.exportImage': 'Export image…';
|
|
199
|
+
readonly 'menu.exportBundle': 'Save with images';
|
|
200
|
+
readonly 'menu.reset': 'Reset the canvas';
|
|
201
|
+
readonly 'menu.resetConfirm': 'This will clear the whole canvas. Continue?';
|
|
202
|
+
readonly 'menu.shortcuts': 'Keyboard shortcuts';
|
|
203
|
+
readonly 'menu.canvas': 'Canvas settings';
|
|
204
|
+
readonly 'link.edit': 'Edit link…';
|
|
205
|
+
readonly 'link.label': 'Link';
|
|
206
|
+
readonly 'link.placeholder': 'Type or paste your link here';
|
|
207
|
+
readonly 'link.change': 'Edit link';
|
|
208
|
+
readonly 'link.save': 'Save';
|
|
209
|
+
readonly 'link.remove': 'Remove link';
|
|
210
|
+
readonly 'link.invalid': 'This link cannot be used here.';
|
|
211
|
+
readonly 'contextMenu.label': 'Context menu';
|
|
212
|
+
readonly 'export.title': 'Export image';
|
|
213
|
+
readonly 'export.format': 'Format';
|
|
214
|
+
readonly 'export.selectionOnly': 'Only selected';
|
|
215
|
+
readonly 'export.background': 'Background';
|
|
216
|
+
readonly 'export.grid': 'Include grid';
|
|
217
|
+
readonly 'export.scale': 'Scale';
|
|
218
|
+
readonly 'export.padding': 'Padding';
|
|
219
|
+
readonly 'export.download': 'Download';
|
|
220
|
+
readonly 'export.warnings': '{count, plural, one {# warning} other {# warnings}}';
|
|
221
|
+
readonly 'shortcuts.title': 'Keyboard shortcuts';
|
|
222
|
+
readonly 'shortcuts.search': 'Search shortcuts';
|
|
223
|
+
readonly 'shortcuts.tools': 'Tools';
|
|
224
|
+
readonly 'shortcuts.commands': 'Editor';
|
|
225
|
+
readonly 'dialog.close': 'Close';
|
|
226
|
+
readonly 'minimap.label': 'Minimap';
|
|
227
|
+
readonly 'minimap.toggle': 'Toggle minimap';
|
|
228
|
+
readonly 'error.import': 'Could not open the file: {message}';
|
|
229
|
+
};
|
|
230
|
+
type MessageKey = keyof typeof en;
|
|
231
|
+
interface LanguageInfo {
|
|
232
|
+
readonly locale: string;
|
|
233
|
+
/** Name in the language itself, for the language picker. */
|
|
234
|
+
readonly name: string;
|
|
235
|
+
/** Loads the catalog on first use (English is built in and has none). */
|
|
236
|
+
readonly load?: () => Promise<Messages>;
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* Built-in languages, offered in the main menu's language picker under their own names.
|
|
240
|
+
* Catalogs other than English are separate chunks, loaded when a locale first needs them.
|
|
241
|
+
*/
|
|
242
|
+
declare const LANGUAGES: readonly LanguageInfo[];
|
|
243
|
+
/**
|
|
244
|
+
* Built-in catalog for a locale (`de-AT` falls back to `de`) once it has loaded, else
|
|
245
|
+
* `undefined` (always for English). See {@link loadMessages}.
|
|
246
|
+
*/
|
|
247
|
+
declare function builtinMessages(locale: string): Messages | undefined;
|
|
248
|
+
/** Whether `locale` has a built-in catalog that is not loaded yet. */
|
|
249
|
+
declare function needsMessages(locale: string): boolean;
|
|
250
|
+
/**
|
|
251
|
+
* Loads the built-in catalog for `locale` (once; later calls share the result). Await it
|
|
252
|
+
* before mounting to render a non-English editor without first showing English.
|
|
253
|
+
*/
|
|
254
|
+
declare function loadMessages(locale: string): Promise<Messages | undefined>;
|
|
255
|
+
type Messages = { readonly [Key in MessageKey]?: string; } & {
|
|
256
|
+
readonly [key: string]: string | undefined;
|
|
257
|
+
};
|
|
258
|
+
type TranslateValues = Readonly<Record<string, string | number>>;
|
|
259
|
+
type Translate = (key: MessageKey | (string & {}), values?: TranslateValues) => string;
|
|
260
|
+
/**
|
|
261
|
+
* Translator over a message catalog: `{name}` interpolation and
|
|
262
|
+
* `{count, plural, one {…} other {…}}` with `#` for the number (`Intl.PluralRules`).
|
|
263
|
+
*/
|
|
264
|
+
declare function createTranslator(messages?: Messages, locale?: string): Translate;
|
|
265
|
+
export { Translate as a, createTranslator as c, needsMessages as d, Messages as i, en as l, LanguageInfo as n, TranslateValues as o, MessageKey as r, builtinMessages as s, LANGUAGES as t, loadMessages as u };
|