1a87937973
* Add back overflow:hidden to field descriptions * Add explaining comment * Put back overflow:hidden in FieldsEditor * Move inline padding from Fields component but EditorField+LabelContainer * Simplify editor design by making editor toolbar not sticky * Make tag editor in note editor non-sticky as well * Fix merge mess * The floating elements were portaled because I passed in undefined and they have a default argument - Fix unrelated to PR
37 lines
774 B
TypeScript
37 lines
774 B
TypeScript
// Copyright: Ankitects Pty Ltd and contributors
|
|
// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|
|
|
/**
|
|
* @param element: The element to be moved.
|
|
* @param target DOM Element where element is going to be appended
|
|
*/
|
|
function portal(
|
|
element: HTMLElement,
|
|
targetElement: Element | null = document.body,
|
|
): { update(target: Element): void; destroy(): void } {
|
|
let target: Element | null;
|
|
|
|
async function update(newTarget: Element | null) {
|
|
target = newTarget;
|
|
|
|
if (!target) {
|
|
return;
|
|
}
|
|
|
|
target.append(element);
|
|
}
|
|
|
|
function destroy() {
|
|
element.remove();
|
|
}
|
|
|
|
update(targetElement);
|
|
|
|
return {
|
|
update,
|
|
destroy,
|
|
};
|
|
}
|
|
|
|
export default portal;
|