mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-14 21:27:20 +00:00
refactor(editor): group and expose parameters of createButtonPopper (#10999)
This commit is contained in:
@@ -32,6 +32,17 @@ export function listenClickAway(
|
||||
type Display = 'show' | 'hidden';
|
||||
|
||||
const ATTR_SHOW = 'data-show';
|
||||
|
||||
export type ButtonPopperOptions = {
|
||||
reference: HTMLElement;
|
||||
popperElement: HTMLElement;
|
||||
stateUpdated?: (state: { display: Display }) => void;
|
||||
mainAxis?: number;
|
||||
crossAxis?: number;
|
||||
rootBoundary?: Rect | (() => Rect | undefined);
|
||||
ignoreShift?: boolean;
|
||||
offsetHeight?: number;
|
||||
};
|
||||
/**
|
||||
* Using attribute 'data-show' to control popper visibility.
|
||||
*
|
||||
@@ -44,28 +55,19 @@ const ATTR_SHOW = 'data-show';
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
export function createButtonPopper(
|
||||
reference: HTMLElement,
|
||||
popperElement: HTMLElement,
|
||||
stateUpdated: (state: { display: Display }) => void = () => {
|
||||
/** DEFAULT EMPTY FUNCTION */
|
||||
},
|
||||
{
|
||||
export function createButtonPopper(options: ButtonPopperOptions) {
|
||||
let display: Display = 'hidden';
|
||||
let cleanup: (() => void) | void;
|
||||
const {
|
||||
reference,
|
||||
popperElement,
|
||||
stateUpdated = () => {},
|
||||
mainAxis,
|
||||
crossAxis,
|
||||
rootBoundary,
|
||||
ignoreShift,
|
||||
offsetHeight,
|
||||
}: {
|
||||
mainAxis?: number;
|
||||
crossAxis?: number;
|
||||
rootBoundary?: Rect | (() => Rect | undefined);
|
||||
ignoreShift?: boolean;
|
||||
offsetHeight?: number;
|
||||
} = {}
|
||||
) {
|
||||
let display: Display = 'hidden';
|
||||
let cleanup: (() => void) | void;
|
||||
} = options;
|
||||
|
||||
const originMaxHeight = window.getComputedStyle(popperElement).maxHeight;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user