| 12345678910111213141516171819202122232425262728293031323334353637 |
- import type { IPage, IPagePopulatedToShowRevision } from '@growi/core';
- import { useIsContainerFluid } from '~/stores/context';
- import { useEditorMode } from '~/stores/ui';
- export const useEditorModeClassName = (): string => {
- const { getClassNamesByEditorMode } = useEditorMode();
- return `${getClassNamesByEditorMode().join(' ') ?? ''}`;
- };
- const useDetermineExpandContent = (expandContentWidth?: boolean | null): boolean => {
- const { data: dataIsContainerFluid } = useIsContainerFluid();
- const isContainerFluidDefault = dataIsContainerFluid;
- return expandContentWidth ?? isContainerFluidDefault ?? false;
- };
- export const useShouldExpandContent = (data?: IPage | IPagePopulatedToShowRevision | boolean | null): boolean => {
- const expandContentWidth = (() => {
- // when data is null
- if (data == null) {
- return null;
- }
- // when data is boolean
- if (data === true || data === false) {
- return data;
- }
- // when IPage does not have expandContentWidth
- if (!('expandContentWidth' in data)) {
- return null;
- }
- return data.expandContentWidth;
- })();
- return useDetermineExpandContent(expandContentWidth);
- };
|