Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,16 @@ const TOOLS = {
text: { label: 'Text', Icon: IconInsertText },
} as const;

type ToolName = keyof typeof TOOLS;

/** Type guard to ensure a given string is a valid ToolName. */
const isToolName = (name: string): name is ToolName => name in TOOLS;

/**
* Editor-bound wrapper rendered through tldraw's `InFrontOfTheCanvas` slot so
* it can read live tool / zoom state via `useEditor`.
*/
export const Tools = () => {
const editor = useEditor();

const tool = useValue('tool', () => editor.getCurrentToolId(), [editor]);

// Here we map the tldraw tool to one of our supported ones. If it's not found
// we fallback to default 'select' tool
const activeToolName: ToolName = isToolName(tool) ? tool : 'select';
const activeToolName = useValue('tool', () => {
return editor.getCurrentToolId();
}, [editor]);

return (
<div
Expand Down
13 changes: 13 additions & 0 deletions dataweaver/apps/web/src/components/scopes/atlas/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ const DISABLED_ACTION_IDS = [
'flatten-to-image',
'toggle-lock',

// Flip selection (Shift+H / Shift+V)
'flip-horizontal',
'flip-vertical',

// Export as… (also lives in our own toolbar UI)
'export-as-svg',
'export-as-png',
Expand All @@ -41,12 +45,21 @@ const DISABLED_ACTION_IDS = [
'move-to-new-page',
] as const;

/**
* List of tools we don't want to support.
*/
const DISABLED_TOOL_IDS = ['frame'] as const;

/** UI behaviour overrides for tldraw. */
export const ATLAS_OVERRIDES: TLUiOverrides = {
actions(_editor, actions) {
for (const id of DISABLED_ACTION_IDS) delete actions[id];
return actions;
},
tools(_editor, tools) {
for (const id of DISABLED_TOOL_IDS) delete tools[id];
return tools;
},
};

/** The shapes that Atlas supports. */
Expand Down