publish handleLinkNavigation to app props
This commit is contained in:
parent
de6371aac4
commit
e4b17e77f8
@ -2394,6 +2394,14 @@ class App extends React.Component<AppProps, AppState> {
|
||||
if (lastPointerDownHittingLinkIcon && LastPointerUpHittingLinkIcon) {
|
||||
const url = this.hitLinkElement?.link;
|
||||
if (url) {
|
||||
if (this.props.handleLinkNavigation) {
|
||||
try {
|
||||
this.props.handleLinkNavigation(url);
|
||||
return;
|
||||
} catch (error: any) {
|
||||
console.error(error);
|
||||
}
|
||||
}
|
||||
const target = isLocalLink(url) ? "_self" : "_blank";
|
||||
const newWindow = window.open(undefined, target);
|
||||
// https://mathiasbynens.github.io/rel-noopener/
|
||||
|
@ -17,6 +17,10 @@ Please add the latest change on the top under the correct section.
|
||||
|
||||
- [`exportToBlob`](https://github.com/excalidraw/excalidraw/blob/master/src/packages/excalidraw/README.md#exportToBlob) now automatically sets `appState.exportBackground` to `true` if exporting to `image/jpeg` MIME type (to ensure that alpha channel is not compressed to black color).
|
||||
|
||||
## Excalidraw App Props
|
||||
|
||||
- `handleLinkNavigation (url: string) => void`. If provided Excalidraw will call this function to open element hyperlinks.
|
||||
|
||||
### Features
|
||||
|
||||
- Support updating library using [`updateScene`](https://github.com/excalidraw/excalidraw/blob/master/src/packages/excalidraw/README.md#updateScene) API [#4546](https://github.com/excalidraw/excalidraw/pull/4546).
|
||||
|
@ -405,6 +405,7 @@ For a complete list of variables, check [theme.scss](https://github.com/excalidr
|
||||
| [`onLibraryChange`](#onLibraryChange) | <pre>(items: <a href="https://github.com/excalidraw/excalidraw/blob/master/src/types.ts#L200">LibraryItems</a>) => void | Promise<any> </pre> | | The callback if supplied is triggered when the library is updated and receives the library items. |
|
||||
| [`autoFocus`](#autoFocus) | boolean | false | Implies whether to focus the Excalidraw component on page load |
|
||||
| [`generateIdForFile`](#generateIdForFile) | `(file: File) => string | Promise<string>` | Allows you to override `id` generation for files added on canvas |
|
||||
| [`handleLinkNavigation`](#handleLinkNavigation) | `(url: string) => void` | If provided Excalidraw will call this function to open element hyperlinks |
|
||||
|
||||
### Dimensions of Excalidraw
|
||||
|
||||
|
@ -35,6 +35,7 @@ const Excalidraw = (props: ExcalidrawProps) => {
|
||||
onLibraryChange,
|
||||
autoFocus = false,
|
||||
generateIdForFile,
|
||||
handleLinkNavigation,
|
||||
} = props;
|
||||
|
||||
const canvasActions = props.UIOptions?.canvasActions;
|
||||
@ -96,6 +97,7 @@ const Excalidraw = (props: ExcalidrawProps) => {
|
||||
onLibraryChange={onLibraryChange}
|
||||
autoFocus={autoFocus}
|
||||
generateIdForFile={generateIdForFile}
|
||||
handleLinkNavigation={handleLinkNavigation}
|
||||
/>
|
||||
</InitializeApp>
|
||||
);
|
||||
|
@ -247,6 +247,7 @@ export interface ExcalidrawProps {
|
||||
onLibraryChange?: (libraryItems: LibraryItems) => void | Promise<any>;
|
||||
autoFocus?: boolean;
|
||||
generateIdForFile?: (file: File) => string | Promise<string>;
|
||||
handleLinkNavigation?: (url: string) => void;
|
||||
}
|
||||
|
||||
export type SceneData = {
|
||||
|
Loading…
x
Reference in New Issue
Block a user