Commit 90af4bb7 authored by Alejandro Celaya's avatar Alejandro Celaya Committed by Alejandro Celaya

Migrate placeholder module to TypeScript

parent aa5e4097
...@@ -16,10 +16,10 @@ const placeholderSelector = '.annotator-placeholder'; ...@@ -16,10 +16,10 @@ const placeholderSelector = '.annotator-placeholder';
* When the viewport is scrolled to the non-rendered page, the placeholder * When the viewport is scrolled to the non-rendered page, the placeholder
* is removed and annotations are re-anchored to the real content. * is removed and annotations are re-anchored to the real content.
* *
* @param {HTMLElement} container - The container element for the page or tile * @param container - The container element for the page or tile which is not
* which is not rendered. * rendered.
*/ */
export function createPlaceholder(container) { export function createPlaceholder(container: HTMLElement) {
let placeholder = container.querySelector(placeholderSelector); let placeholder = container.querySelector(placeholderSelector);
if (placeholder) { if (placeholder) {
return placeholder; return placeholder;
...@@ -33,19 +33,15 @@ export function createPlaceholder(container) { ...@@ -33,19 +33,15 @@ export function createPlaceholder(container) {
/** /**
* Return true if a page/tile container has a placeholder. * Return true if a page/tile container has a placeholder.
*
* @param {HTMLElement} container
*/ */
export function hasPlaceholder(container) { export function hasPlaceholder(container: HTMLElement): boolean {
return container.querySelector(placeholderSelector) !== null; return container.querySelector(placeholderSelector) !== null;
} }
/** /**
* Remove the placeholder element in `container`, if present. * Remove the placeholder element in `container`, if present.
*
* @param {HTMLElement} container
*/ */
export function removePlaceholder(container) { export function removePlaceholder(container: HTMLElement) {
container.querySelector(placeholderSelector)?.remove(); container.querySelector(placeholderSelector)?.remove();
} }
...@@ -54,10 +50,8 @@ export function removePlaceholder(container) { ...@@ -54,10 +50,8 @@ export function removePlaceholder(container) {
* *
* This is typically used to test if a highlight element associated with an * This is typically used to test if a highlight element associated with an
* anchor is inside a placeholder. * anchor is inside a placeholder.
*
* @param {Node} node
*/ */
export function isInPlaceholder(node) { export function isInPlaceholder(node: Node): boolean {
if (!node.parentElement) { if (!node.parentElement) {
return false; return false;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment