Skip to content

Commit

Permalink
Merge pull request #2719 from NDLANO/feat/get-closest-editor
Browse files Browse the repository at this point in the history
feat: getClosestEditor
  • Loading branch information
Jonas-C authored Feb 18, 2025
2 parents b029fc7 + 06b14f6 commit 4e6f61b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/editor-components/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ export { useListToolbarButton, useListToolbarButtonState } from "./hooks/useList
export { useMarkToolbarButton, useMarkToolbarButtonState } from "./hooks/useMarkToolbarButton";

export { platformSpecificTooltip } from "./utils/platformSpecificTooltip";
export { getClosestEditor } from "./utils/getClosestEditor";
11 changes: 11 additions & 0 deletions packages/editor-components/src/utils/getClosestEditor.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/**
* Copyright (c) 2025-present, NDLA.
*
* This source code is licensed under the GPLv3 license found in the
* LICENSE file in the root directory of this source tree.
*
*/

export const getClosestEditor = (el: HTMLElement | null): HTMLElement | null => {
return el?.closest("[data-slate-editor]") as HTMLElement | null;
};

0 comments on commit 4e6f61b

Please sign in to comment.