mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-18 20:49:36 +01:00
editor: expose link opening logic to clients (#969)
This commit is contained in:
@@ -61,6 +61,7 @@ export type EditorController = {
|
||||
content: MutableRefObject<string | null>;
|
||||
onUpdate: () => void;
|
||||
titlePlaceholder: string;
|
||||
openLink: (url: string) => boolean;
|
||||
setTitlePlaceholder: React.Dispatch<React.SetStateAction<string>>;
|
||||
};
|
||||
|
||||
@@ -154,6 +155,11 @@ export function useEditorController(update: () => void): EditorController {
|
||||
post(EventTypes.download, attachment);
|
||||
}, []);
|
||||
|
||||
const openLink = useCallback((url: string) => {
|
||||
post(EventTypes.link, url);
|
||||
return true;
|
||||
}, []);
|
||||
|
||||
return {
|
||||
contentChange,
|
||||
selectionChange,
|
||||
@@ -166,6 +172,7 @@ export function useEditorController(update: () => void): EditorController {
|
||||
openFilePicker,
|
||||
downloadAttachment,
|
||||
content: htmlContentRef,
|
||||
openLink,
|
||||
onUpdate: onUpdate
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user