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) {
|
if (lastPointerDownHittingLinkIcon && LastPointerUpHittingLinkIcon) {
|
||||||
const url = this.hitLinkElement?.link;
|
const url = this.hitLinkElement?.link;
|
||||||
if (url) {
|
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 target = isLocalLink(url) ? "_self" : "_blank";
|
||||||
const newWindow = window.open(undefined, target);
|
const newWindow = window.open(undefined, target);
|
||||||
// https://mathiasbynens.github.io/rel-noopener/
|
// 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).
|
- [`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
|
### 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).
|
- 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. |
|
| [`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 |
|
| [`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 |
|
| [`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
|
### Dimensions of Excalidraw
|
||||||
|
|
||||||
|
@ -35,6 +35,7 @@ const Excalidraw = (props: ExcalidrawProps) => {
|
|||||||
onLibraryChange,
|
onLibraryChange,
|
||||||
autoFocus = false,
|
autoFocus = false,
|
||||||
generateIdForFile,
|
generateIdForFile,
|
||||||
|
handleLinkNavigation,
|
||||||
} = props;
|
} = props;
|
||||||
|
|
||||||
const canvasActions = props.UIOptions?.canvasActions;
|
const canvasActions = props.UIOptions?.canvasActions;
|
||||||
@ -96,6 +97,7 @@ const Excalidraw = (props: ExcalidrawProps) => {
|
|||||||
onLibraryChange={onLibraryChange}
|
onLibraryChange={onLibraryChange}
|
||||||
autoFocus={autoFocus}
|
autoFocus={autoFocus}
|
||||||
generateIdForFile={generateIdForFile}
|
generateIdForFile={generateIdForFile}
|
||||||
|
handleLinkNavigation={handleLinkNavigation}
|
||||||
/>
|
/>
|
||||||
</InitializeApp>
|
</InitializeApp>
|
||||||
);
|
);
|
||||||
|
@ -247,6 +247,7 @@ export interface ExcalidrawProps {
|
|||||||
onLibraryChange?: (libraryItems: LibraryItems) => void | Promise<any>;
|
onLibraryChange?: (libraryItems: LibraryItems) => void | Promise<any>;
|
||||||
autoFocus?: boolean;
|
autoFocus?: boolean;
|
||||||
generateIdForFile?: (file: File) => string | Promise<string>;
|
generateIdForFile?: (file: File) => string | Promise<string>;
|
||||||
|
handleLinkNavigation?: (url: string) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type SceneData = {
|
export type SceneData = {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user