Compare commits
2 Commits
master
...
dwelle/pro
Author | SHA1 | Date | |
---|---|---|---|
![]() |
cb2bf44997 | ||
![]() |
c199686c05 |
@ -30,6 +30,7 @@ All `props` are *optional*.
|
|||||||
| [`generateIdForFile`](#generateidforfile) | `function` | _ | Allows you to override `id` generation for files added on canvas |
|
| [`generateIdForFile`](#generateidforfile) | `function` | _ | Allows you to override `id` generation for files added on canvas |
|
||||||
| [`validateEmbeddable`](#validateEmbeddable) | string[] | `boolean | RegExp | RegExp[] | ((link: string) => boolean | undefined)` | \_ | use for custom src url validation |
|
| [`validateEmbeddable`](#validateEmbeddable) | string[] | `boolean | RegExp | RegExp[] | ((link: string) => boolean | undefined)` | \_ | use for custom src url validation |
|
||||||
| [`renderEmbeddable`](/docs/@excalidraw/excalidraw/api/props/render-props#renderEmbeddable) | `function` | \_ | Render function that can override the built-in `<iframe>` |
|
| [`renderEmbeddable`](/docs/@excalidraw/excalidraw/api/props/render-props#renderEmbeddable) | `function` | \_ | Render function that can override the built-in `<iframe>` |
|
||||||
|
| [`activeTool`](#activeTool) | `object` | - | Set the active editor tool (forced) |
|
||||||
|
|
||||||
### Storing custom data on Excalidraw elements
|
### Storing custom data on Excalidraw elements
|
||||||
|
|
||||||
@ -236,4 +237,19 @@ validateEmbeddable?: boolean | string[] | RegExp | RegExp[] | ((link: string) =>
|
|||||||
|
|
||||||
This is an optional property. By default we support a handful of well-known sites. You may allow additional sites or disallow the default ones by supplying a custom validator. If you pass `true`, all URLs will be allowed. You can also supply a list of hostnames, RegExp (or list of RegExp objects), or a function. If the function returns `undefined`, the built-in validator will be used.
|
This is an optional property. By default we support a handful of well-known sites. You may allow additional sites or disallow the default ones by supplying a custom validator. If you pass `true`, all URLs will be allowed. You can also supply a list of hostnames, RegExp (or list of RegExp objects), or a function. If the function returns `undefined`, the built-in validator will be used.
|
||||||
|
|
||||||
Supplying a list of hostnames (with or without `www.`) is the preferred way to allow a specific list of domains.
|
Supplying a list of hostnames (with or without `www.`) is the preferred way to allow a specific list of domains.
|
||||||
|
|
||||||
|
### activeTool
|
||||||
|
|
||||||
|
```ts
|
||||||
|
activeTool?:
|
||||||
|
| {
|
||||||
|
type: ToolType;
|
||||||
|
}
|
||||||
|
| {
|
||||||
|
type: "custom";
|
||||||
|
customType: string;
|
||||||
|
};
|
||||||
|
```
|
||||||
|
|
||||||
|
Tool to be force-set as active. As long as the prop is set, the editor active tool will be set to this. Useful only in specific circumstances such as when UI is disabled and the editor should be limited to just one tool (such as a laser pointer).
|
@ -1903,6 +1903,13 @@ class App extends React.Component<AppProps, AppState> {
|
|||||||
this.refreshDeviceState(this.excalidrawContainerRef.current);
|
this.refreshDeviceState(this.excalidrawContainerRef.current);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
this.props.activeTool &&
|
||||||
|
this.props.activeTool.type !== this.state.activeTool.type
|
||||||
|
) {
|
||||||
|
this.setActiveTool(this.props.activeTool);
|
||||||
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
prevState.scrollX !== this.state.scrollX ||
|
prevState.scrollX !== this.state.scrollX ||
|
||||||
prevState.scrollY !== this.state.scrollY
|
prevState.scrollY !== this.state.scrollY
|
||||||
@ -3136,11 +3143,7 @@ class App extends React.Component<AppProps, AppState> {
|
|||||||
| { type: "custom"; customType: string },
|
| { type: "custom"; customType: string },
|
||||||
) => {
|
) => {
|
||||||
const nextActiveTool = updateActiveTool(this.state, tool);
|
const nextActiveTool = updateActiveTool(this.state, tool);
|
||||||
if (nextActiveTool.type === "hand") {
|
|
||||||
setCursor(this.interactiveCanvas, CURSOR_TYPE.GRAB);
|
|
||||||
} else if (!isHoldingSpace) {
|
|
||||||
setCursorForShape(this.interactiveCanvas, this.state);
|
|
||||||
}
|
|
||||||
if (isToolIcon(document.activeElement)) {
|
if (isToolIcon(document.activeElement)) {
|
||||||
this.focusContainer();
|
this.focusContainer();
|
||||||
}
|
}
|
||||||
@ -3157,8 +3160,10 @@ class App extends React.Component<AppProps, AppState> {
|
|||||||
originSnapOffset: null,
|
originSnapOffset: null,
|
||||||
activeEmbeddable: null,
|
activeEmbeddable: null,
|
||||||
} as const;
|
} as const;
|
||||||
|
let nextState: AppState;
|
||||||
|
|
||||||
if (nextActiveTool.type !== "selection") {
|
if (nextActiveTool.type !== "selection") {
|
||||||
return {
|
nextState = {
|
||||||
...prevState,
|
...prevState,
|
||||||
activeTool: nextActiveTool,
|
activeTool: nextActiveTool,
|
||||||
selectedElementIds: makeNextSelectedElementIds({}, prevState),
|
selectedElementIds: makeNextSelectedElementIds({}, prevState),
|
||||||
@ -3167,12 +3172,21 @@ class App extends React.Component<AppProps, AppState> {
|
|||||||
multiElement: null,
|
multiElement: null,
|
||||||
...commonResets,
|
...commonResets,
|
||||||
};
|
};
|
||||||
|
} else {
|
||||||
|
nextState = {
|
||||||
|
...prevState,
|
||||||
|
activeTool: nextActiveTool,
|
||||||
|
...commonResets,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
return {
|
|
||||||
...prevState,
|
if (nextActiveTool.type === "hand") {
|
||||||
activeTool: nextActiveTool,
|
setCursor(this.interactiveCanvas, CURSOR_TYPE.GRAB);
|
||||||
...commonResets,
|
} else if (!isHoldingSpace) {
|
||||||
};
|
setCursorForShape(this.interactiveCanvas, nextState);
|
||||||
|
}
|
||||||
|
|
||||||
|
return nextState;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -44,6 +44,7 @@ const ExcalidrawBase = (props: ExcalidrawProps) => {
|
|||||||
children,
|
children,
|
||||||
validateEmbeddable,
|
validateEmbeddable,
|
||||||
renderEmbeddable,
|
renderEmbeddable,
|
||||||
|
activeTool,
|
||||||
} = props;
|
} = props;
|
||||||
|
|
||||||
const canvasActions = props.UIOptions?.canvasActions;
|
const canvasActions = props.UIOptions?.canvasActions;
|
||||||
@ -119,6 +120,7 @@ const ExcalidrawBase = (props: ExcalidrawProps) => {
|
|||||||
onScrollChange={onScrollChange}
|
onScrollChange={onScrollChange}
|
||||||
validateEmbeddable={validateEmbeddable}
|
validateEmbeddable={validateEmbeddable}
|
||||||
renderEmbeddable={renderEmbeddable}
|
renderEmbeddable={renderEmbeddable}
|
||||||
|
activeTool={activeTool}
|
||||||
>
|
>
|
||||||
{children}
|
{children}
|
||||||
</App>
|
</App>
|
||||||
|
@ -445,6 +445,14 @@ export interface ExcalidrawProps {
|
|||||||
element: NonDeleted<ExcalidrawEmbeddableElement>,
|
element: NonDeleted<ExcalidrawEmbeddableElement>,
|
||||||
appState: AppState,
|
appState: AppState,
|
||||||
) => JSX.Element | null;
|
) => JSX.Element | null;
|
||||||
|
activeTool?:
|
||||||
|
| {
|
||||||
|
type: ToolType;
|
||||||
|
}
|
||||||
|
| {
|
||||||
|
type: "custom";
|
||||||
|
customType: string;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export type SceneData = {
|
export type SceneData = {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user