menu: export followup with different semantics for file menu (#2968)
Renamed Object → Shape Different semantics for Export under file menu. Thanks @TodePond ! ### Change Type - [x] `patch` — Bug fix
This commit is contained in:
parent
98850eb043
commit
2a8ae6188e
12 changed files with 161 additions and 62 deletions
|
@ -9,8 +9,8 @@ import {
|
||||||
EditSubmenu,
|
EditSubmenu,
|
||||||
Editor,
|
Editor,
|
||||||
ExtrasGroup,
|
ExtrasGroup,
|
||||||
ObjectSubmenu,
|
|
||||||
PreferencesGroup,
|
PreferencesGroup,
|
||||||
|
ShapeSubmenu,
|
||||||
TLComponents,
|
TLComponents,
|
||||||
Tldraw,
|
Tldraw,
|
||||||
TldrawUiMenuGroup,
|
TldrawUiMenuGroup,
|
||||||
|
@ -49,7 +49,7 @@ const components: TLComponents = {
|
||||||
<DefaultMainMenu>
|
<DefaultMainMenu>
|
||||||
<LocalFileMenu />
|
<LocalFileMenu />
|
||||||
<EditSubmenu />
|
<EditSubmenu />
|
||||||
<ObjectSubmenu />
|
<ShapeSubmenu />
|
||||||
<ViewSubmenu />
|
<ViewSubmenu />
|
||||||
<ExtrasGroup />
|
<ExtrasGroup />
|
||||||
<PreferencesGroup />
|
<PreferencesGroup />
|
||||||
|
|
|
@ -9,9 +9,9 @@ import {
|
||||||
EditSubmenu,
|
EditSubmenu,
|
||||||
Editor,
|
Editor,
|
||||||
ExtrasGroup,
|
ExtrasGroup,
|
||||||
ObjectSubmenu,
|
|
||||||
OfflineIndicator,
|
OfflineIndicator,
|
||||||
PreferencesGroup,
|
PreferencesGroup,
|
||||||
|
ShapeSubmenu,
|
||||||
TLComponents,
|
TLComponents,
|
||||||
Tldraw,
|
Tldraw,
|
||||||
TldrawUiMenuGroup,
|
TldrawUiMenuGroup,
|
||||||
|
@ -69,7 +69,7 @@ const components: TLComponents = {
|
||||||
<DefaultMainMenu>
|
<DefaultMainMenu>
|
||||||
<MultiplayerFileMenu />
|
<MultiplayerFileMenu />
|
||||||
<EditSubmenu />
|
<EditSubmenu />
|
||||||
<ObjectSubmenu />
|
<ShapeSubmenu />
|
||||||
<ViewSubmenu />
|
<ViewSubmenu />
|
||||||
<ExtrasGroup />
|
<ExtrasGroup />
|
||||||
<PreferencesGroup />
|
<PreferencesGroup />
|
||||||
|
|
|
@ -36,6 +36,12 @@
|
||||||
"action.export-as-png": "Export as PNG",
|
"action.export-as-png": "Export as PNG",
|
||||||
"action.export-as-svg.short": "SVG",
|
"action.export-as-svg.short": "SVG",
|
||||||
"action.export-as-svg": "Export as SVG",
|
"action.export-as-svg": "Export as SVG",
|
||||||
|
"action.export-all-as-json.short": "JSON",
|
||||||
|
"action.export-all-as-json": "Export all as JSON",
|
||||||
|
"action.export-all-as-png.short": "PNG",
|
||||||
|
"action.export-all-as-png": "Export all as PNG",
|
||||||
|
"action.export-all-as-svg.short": "SVG",
|
||||||
|
"action.export-all-as-svg": "Export all as SVG",
|
||||||
"action.fit-frame-to-content": "Fit to content",
|
"action.fit-frame-to-content": "Fit to content",
|
||||||
"action.flip-horizontal": "Flip horizontally",
|
"action.flip-horizontal": "Flip horizontally",
|
||||||
"action.flip-vertical": "Flip vertically",
|
"action.flip-vertical": "Flip vertically",
|
||||||
|
@ -215,7 +221,7 @@
|
||||||
"menu.title": "Menu",
|
"menu.title": "Menu",
|
||||||
"menu.copy-as": "Copy as",
|
"menu.copy-as": "Copy as",
|
||||||
"menu.edit": "Edit",
|
"menu.edit": "Edit",
|
||||||
"menu.object": "Object",
|
"menu.shape": "Shape",
|
||||||
"menu.export-as": "Export as",
|
"menu.export-as": "Export as",
|
||||||
"menu.file": "File",
|
"menu.file": "File",
|
||||||
"menu.language": "Language",
|
"menu.language": "Language",
|
||||||
|
@ -224,6 +230,7 @@
|
||||||
"context-menu.arrange": "Arrange",
|
"context-menu.arrange": "Arrange",
|
||||||
"context-menu.copy-as": "Copy as",
|
"context-menu.copy-as": "Copy as",
|
||||||
"context-menu.export-as": "Export as",
|
"context-menu.export-as": "Export as",
|
||||||
|
"context-menu.export-all-as": "Export all as",
|
||||||
"context-menu.move-to-page": "Move to page",
|
"context-menu.move-to-page": "Move to page",
|
||||||
"context-menu.reorder": "Reorder",
|
"context-menu.reorder": "Reorder",
|
||||||
"page-menu.title": "Pages",
|
"page-menu.title": "Pages",
|
||||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -185,8 +185,8 @@ export {
|
||||||
EditSubmenu,
|
EditSubmenu,
|
||||||
ExportFileContentSubMenu,
|
ExportFileContentSubMenu,
|
||||||
ExtrasGroup,
|
ExtrasGroup,
|
||||||
ObjectSubmenu,
|
|
||||||
PreferencesGroup,
|
PreferencesGroup,
|
||||||
|
ShapeSubmenu,
|
||||||
ViewSubmenu,
|
ViewSubmenu,
|
||||||
} from './lib/ui/components/MainMenu/DefaultMainMenuContent'
|
} from './lib/ui/components/MainMenu/DefaultMainMenuContent'
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,7 @@ export function DefaultMainMenuContent() {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<EditSubmenu />
|
<EditSubmenu />
|
||||||
<ObjectSubmenu />
|
<ShapeSubmenu />
|
||||||
<ViewSubmenu />
|
<ViewSubmenu />
|
||||||
<ExtrasGroup />
|
<ExtrasGroup />
|
||||||
<PreferencesGroup />
|
<PreferencesGroup />
|
||||||
|
@ -50,13 +50,13 @@ export function ExportFileContentSubMenu() {
|
||||||
const actions = useActions()
|
const actions = useActions()
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<TldrawUiMenuSubmenu id="export-as" label="context-menu.export-as" size="small">
|
<TldrawUiMenuSubmenu id="export-all-as" label="context-menu.export-all-as" size="small">
|
||||||
<TldrawUiMenuGroup id="export-as-group">
|
<TldrawUiMenuGroup id="export-all-as-group">
|
||||||
<TldrawUiMenuItem {...actions['export-as-svg']} />
|
<TldrawUiMenuItem {...actions['export-all-as-svg']} />
|
||||||
<TldrawUiMenuItem {...actions['export-as-png']} />
|
<TldrawUiMenuItem {...actions['export-all-as-png']} />
|
||||||
<TldrawUiMenuItem {...actions['export-as-json']} />
|
<TldrawUiMenuItem {...actions['export-all-as-json']} />
|
||||||
</TldrawUiMenuGroup>
|
</TldrawUiMenuGroup>
|
||||||
<TldrawUiMenuGroup id="export-as-bg">
|
<TldrawUiMenuGroup id="export-all-as-bg">
|
||||||
<ToggleTransparentBgMenuItem />
|
<ToggleTransparentBgMenuItem />
|
||||||
</TldrawUiMenuGroup>
|
</TldrawUiMenuGroup>
|
||||||
</TldrawUiMenuSubmenu>
|
</TldrawUiMenuSubmenu>
|
||||||
|
@ -83,7 +83,7 @@ export function EditSubmenu() {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @public */
|
/** @public */
|
||||||
export function ObjectSubmenu() {
|
export function ShapeSubmenu() {
|
||||||
const editor = useEditor()
|
const editor = useEditor()
|
||||||
|
|
||||||
const selectToolActive = useValue(
|
const selectToolActive = useValue(
|
||||||
|
@ -93,7 +93,7 @@ export function ObjectSubmenu() {
|
||||||
)
|
)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<TldrawUiMenuSubmenu id="object" label="menu.object" disabled={!selectToolActive}>
|
<TldrawUiMenuSubmenu id="shape" label="menu.shape" disabled={!selectToolActive}>
|
||||||
<ConversionsMenuGroup />
|
<ConversionsMenuGroup />
|
||||||
<MultiShapeMenuGroup />
|
<MultiShapeMenuGroup />
|
||||||
<MiscMenuGroup />
|
<MiscMenuGroup />
|
||||||
|
|
|
@ -234,13 +234,8 @@ export function PasteMenuItem() {
|
||||||
/* ------------------- Conversions ------------------ */
|
/* ------------------- Conversions ------------------ */
|
||||||
|
|
||||||
export function ConversionsMenuGroup() {
|
export function ConversionsMenuGroup() {
|
||||||
const editor = useEditor()
|
|
||||||
const actions = useActions()
|
const actions = useActions()
|
||||||
const atLeastOneShapeOnPage = useValue(
|
const shouldDisplay = useUnlockedSelectedShapesCount(1)
|
||||||
'atLeastOneShapeOnPage',
|
|
||||||
() => editor.getCurrentPageShapeIds().size > 0,
|
|
||||||
[]
|
|
||||||
)
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<TldrawUiMenuGroup id="conversions">
|
<TldrawUiMenuGroup id="conversions">
|
||||||
|
@ -248,7 +243,7 @@ export function ConversionsMenuGroup() {
|
||||||
id="export-as"
|
id="export-as"
|
||||||
label="context-menu.export-as"
|
label="context-menu.export-as"
|
||||||
size="small"
|
size="small"
|
||||||
disabled={!atLeastOneShapeOnPage}
|
disabled={!shouldDisplay}
|
||||||
>
|
>
|
||||||
<TldrawUiMenuGroup id="export-as-group">
|
<TldrawUiMenuGroup id="export-as-group">
|
||||||
<TldrawUiMenuItem {...actions['export-as-svg']} />
|
<TldrawUiMenuItem {...actions['export-as-svg']} />
|
||||||
|
|
|
@ -204,6 +204,57 @@ export function ActionsProvider({ overrides, children }: ActionsProviderProps) {
|
||||||
exportAs(editor.getSelectedShapeIds(), 'json', getExportName(editor, defaultDocumentName))
|
exportAs(editor.getSelectedShapeIds(), 'json', getExportName(editor, defaultDocumentName))
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
id: 'export-all-as-svg',
|
||||||
|
label: {
|
||||||
|
default: 'action.export-all-as-svg',
|
||||||
|
menu: 'action.export-all-as-svg.short',
|
||||||
|
['context-menu']: 'action.export-all-as-svg.short',
|
||||||
|
},
|
||||||
|
readonlyOk: true,
|
||||||
|
onSelect(source) {
|
||||||
|
trackEvent('export-all-as', { format: 'svg', source })
|
||||||
|
exportAs(
|
||||||
|
Array.from(editor.getCurrentPageShapeIds()),
|
||||||
|
'svg',
|
||||||
|
getExportName(editor, defaultDocumentName)
|
||||||
|
)
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'export-all-as-png',
|
||||||
|
label: {
|
||||||
|
default: 'action.export-all-as-png',
|
||||||
|
menu: 'action.export-all-as-png.short',
|
||||||
|
['context-menu']: 'action.export-all-as-png.short',
|
||||||
|
},
|
||||||
|
readonlyOk: true,
|
||||||
|
onSelect(source) {
|
||||||
|
trackEvent('export-all-as', { format: 'png', source })
|
||||||
|
exportAs(
|
||||||
|
Array.from(editor.getCurrentPageShapeIds()),
|
||||||
|
'png',
|
||||||
|
getExportName(editor, defaultDocumentName)
|
||||||
|
)
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'export-all-as-json',
|
||||||
|
label: {
|
||||||
|
default: 'action.export-all-as-json',
|
||||||
|
menu: 'action.export-all-as-json.short',
|
||||||
|
['context-menu']: 'action.export-all-as-json.short',
|
||||||
|
},
|
||||||
|
readonlyOk: true,
|
||||||
|
onSelect(source) {
|
||||||
|
trackEvent('export-all-as', { format: 'json', source })
|
||||||
|
exportAs(
|
||||||
|
Array.from(editor.getCurrentPageShapeIds()),
|
||||||
|
'json',
|
||||||
|
getExportName(editor, defaultDocumentName)
|
||||||
|
)
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
id: 'copy-as-svg',
|
id: 'copy-as-svg',
|
||||||
label: {
|
label: {
|
||||||
|
|
|
@ -40,6 +40,7 @@ export interface TLUiEventMap {
|
||||||
'toggle-auto-size': null
|
'toggle-auto-size': null
|
||||||
'copy-as': { format: 'svg' | 'png' | 'json' }
|
'copy-as': { format: 'svg' | 'png' | 'json' }
|
||||||
'export-as': { format: 'svg' | 'png' | 'json' }
|
'export-as': { format: 'svg' | 'png' | 'json' }
|
||||||
|
'export-all-as': { format: 'svg' | 'png' | 'json' }
|
||||||
'edit-link': null
|
'edit-link': null
|
||||||
'insert-embed': null
|
'insert-embed': null
|
||||||
'insert-media': null
|
'insert-media': null
|
||||||
|
|
|
@ -40,6 +40,12 @@ export type TLUiTranslationKey =
|
||||||
| 'action.export-as-png'
|
| 'action.export-as-png'
|
||||||
| 'action.export-as-svg.short'
|
| 'action.export-as-svg.short'
|
||||||
| 'action.export-as-svg'
|
| 'action.export-as-svg'
|
||||||
|
| 'action.export-all-as-json.short'
|
||||||
|
| 'action.export-all-as-json'
|
||||||
|
| 'action.export-all-as-png.short'
|
||||||
|
| 'action.export-all-as-png'
|
||||||
|
| 'action.export-all-as-svg.short'
|
||||||
|
| 'action.export-all-as-svg'
|
||||||
| 'action.fit-frame-to-content'
|
| 'action.fit-frame-to-content'
|
||||||
| 'action.flip-horizontal'
|
| 'action.flip-horizontal'
|
||||||
| 'action.flip-vertical'
|
| 'action.flip-vertical'
|
||||||
|
@ -219,7 +225,7 @@ export type TLUiTranslationKey =
|
||||||
| 'menu.title'
|
| 'menu.title'
|
||||||
| 'menu.copy-as'
|
| 'menu.copy-as'
|
||||||
| 'menu.edit'
|
| 'menu.edit'
|
||||||
| 'menu.object'
|
| 'menu.shape'
|
||||||
| 'menu.export-as'
|
| 'menu.export-as'
|
||||||
| 'menu.file'
|
| 'menu.file'
|
||||||
| 'menu.language'
|
| 'menu.language'
|
||||||
|
@ -228,6 +234,7 @@ export type TLUiTranslationKey =
|
||||||
| 'context-menu.arrange'
|
| 'context-menu.arrange'
|
||||||
| 'context-menu.copy-as'
|
| 'context-menu.copy-as'
|
||||||
| 'context-menu.export-as'
|
| 'context-menu.export-as'
|
||||||
|
| 'context-menu.export-all-as'
|
||||||
| 'context-menu.move-to-page'
|
| 'context-menu.move-to-page'
|
||||||
| 'context-menu.reorder'
|
| 'context-menu.reorder'
|
||||||
| 'page-menu.title'
|
| 'page-menu.title'
|
||||||
|
|
|
@ -40,6 +40,12 @@ export const DEFAULT_TRANSLATION = {
|
||||||
'action.export-as-png': 'Export as PNG',
|
'action.export-as-png': 'Export as PNG',
|
||||||
'action.export-as-svg.short': 'SVG',
|
'action.export-as-svg.short': 'SVG',
|
||||||
'action.export-as-svg': 'Export as SVG',
|
'action.export-as-svg': 'Export as SVG',
|
||||||
|
'action.export-all-as-json.short': 'JSON',
|
||||||
|
'action.export-all-as-json': 'Export all as JSON',
|
||||||
|
'action.export-all-as-png.short': 'PNG',
|
||||||
|
'action.export-all-as-png': 'Export all as PNG',
|
||||||
|
'action.export-all-as-svg.short': 'SVG',
|
||||||
|
'action.export-all-as-svg': 'Export all as SVG',
|
||||||
'action.fit-frame-to-content': 'Fit to content',
|
'action.fit-frame-to-content': 'Fit to content',
|
||||||
'action.flip-horizontal': 'Flip horizontally',
|
'action.flip-horizontal': 'Flip horizontally',
|
||||||
'action.flip-vertical': 'Flip vertically',
|
'action.flip-vertical': 'Flip vertically',
|
||||||
|
@ -219,7 +225,7 @@ export const DEFAULT_TRANSLATION = {
|
||||||
'menu.title': 'Menu',
|
'menu.title': 'Menu',
|
||||||
'menu.copy-as': 'Copy as',
|
'menu.copy-as': 'Copy as',
|
||||||
'menu.edit': 'Edit',
|
'menu.edit': 'Edit',
|
||||||
'menu.object': 'Object',
|
'menu.shape': 'Shape',
|
||||||
'menu.export-as': 'Export as',
|
'menu.export-as': 'Export as',
|
||||||
'menu.file': 'File',
|
'menu.file': 'File',
|
||||||
'menu.language': 'Language',
|
'menu.language': 'Language',
|
||||||
|
@ -228,6 +234,7 @@ export const DEFAULT_TRANSLATION = {
|
||||||
'context-menu.arrange': 'Arrange',
|
'context-menu.arrange': 'Arrange',
|
||||||
'context-menu.copy-as': 'Copy as',
|
'context-menu.copy-as': 'Copy as',
|
||||||
'context-menu.export-as': 'Export as',
|
'context-menu.export-as': 'Export as',
|
||||||
|
'context-menu.export-all-as': 'Export all as',
|
||||||
'context-menu.move-to-page': 'Move to page',
|
'context-menu.move-to-page': 'Move to page',
|
||||||
'context-menu.reorder': 'Reorder',
|
'context-menu.reorder': 'Reorder',
|
||||||
'page-menu.title': 'Pages',
|
'page-menu.title': 'Pages',
|
||||||
|
|
Loading…
Reference in a new issue