UNPKG

@atlaskit/editor-plugin-table

Version:

Table plugin for the @atlaskit/editor

23 lines 1.18 kB
import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector'; /** * **This hook is only for internal use and should not be used outside of the table plugin.** * * Hook to select a value from the internal table plugin state. * This is a wrapper around `useSharedPluginStateSelector` to provide access to the entire * `TableSharedStateInternal` type. Since tables plugin has a lot of internal state that is not * exposed via the `TableSharedState` type, we need to use this hook to access it in a type safe way. * * @param api The editor API * @param key Key of TableSharedStateInternal to select * @param options * @returns * @example */ export const useInternalTablePluginStateSelector = (api, key, options) => { // Need to disable the eslint rule here because the key is for the TableSharedStateInternal type // and we are using it as a string to access the value in the useSharedPluginStateSelector // which is typed only for the public TableSharedState type. // eslint-disable-next-line @typescript-eslint/no-explicit-any const value = useSharedPluginStateSelector(api, `table.${key}`, options); return value; };