From c3060e0a1070e1511921a712c88a8772c0f479ed Mon Sep 17 00:00:00 2001 From: e11sy <130844513+e11sy@users.noreply.github.com> Date: Fri, 4 Oct 2024 18:27:03 +0300 Subject: [PATCH] update jsdoc descriptions --- src/ListRenderer/ChecklistRenderer.ts | 3 +-- src/ListRenderer/OrderedListRenderer.ts | 4 +-- src/ListRenderer/UnorderedListRenderer.ts | 4 +-- src/ListTabulator/index.ts | 30 +++++++++-------------- src/index.ts | 13 +++++----- src/utils/getSiblings.ts | 4 +-- src/utils/itemHasSublist.ts | 2 +- src/utils/removeChildWrapperIfEmpty.ts | 2 +- 8 files changed, 26 insertions(+), 36 deletions(-) diff --git a/src/ListRenderer/ChecklistRenderer.ts b/src/ListRenderer/ChecklistRenderer.ts index db50a47a..0394aa4f 100644 --- a/src/ListRenderer/ChecklistRenderer.ts +++ b/src/ListRenderer/ChecklistRenderer.ts @@ -81,7 +81,7 @@ export class CheckListRenderer implements ListRendererInterface { listWrapper: ItemChildWrapperElement | undefined; /** - * Returns current List item by the caret position - * @returns + * Getter method to get current item + * @returns current list item or null if caret position is not undefined */ get currentItem(): ItemElement | null { const selection = window.getSelection(); @@ -102,7 +102,7 @@ export default class ListTabulator { * Function that is responsible for rendering nested list with contents * @returns Filled with content wrapper element of the list */ - render() { + render(): ItemChildWrapperElement { this.listWrapper = this.renderer.renderWrapper(true); // fill with data @@ -151,11 +151,8 @@ export default class ListTabulator { /** * Renders children list - * @param list - initialized ListRenderer instance * @param items - items data to append - * @param parentItem - where to append - * @param parentElement - * @returns + * @param parentElement - where to append passed items */ appendItems(items: ListItem[], parentElement: Element): void { items.forEach((item) => { @@ -329,7 +326,7 @@ export default class ListTabulator { /** * Handle UL, OL and LI tags paste and returns List data - * @param element + * @param element - html element that contains whole list * @returns */ pasteHandler(element: PasteEvent['detail']['data']): ListData { @@ -480,7 +477,6 @@ export default class ListTabulator { /** * Reduce indentation for current item * @param event - keydown - * @returns */ shiftTab(event: KeyboardEvent): void { /** @@ -508,8 +504,7 @@ export default class ListTabulator { /** * Decrease indentation of the passed item - * @param item - * @returns + * @param item - list item to be unshifted */ unshiftItem(item: ItemElement): void { if (!item.parentNode) { @@ -691,8 +686,7 @@ export default class ListTabulator { * Method that is used for merging current item with previous one * Content of the current item would be appended to the previous item * Current item children would not change nesting level - * @param currentItem - current item html element - * @param item + * @param item - current item html element */ mergeItemWithPrevious(item: ItemElement): void { const previousItem = item.previousElementSibling; @@ -941,7 +935,6 @@ export default class ListTabulator { /** * Get out from List Tool by Enter on the empty last item * @param index - optional parameter represents index, where would be inseted default block - * @returns */ getOutOfList(index?: number): void { let newBlock; @@ -961,9 +954,8 @@ export default class ListTabulator { /** * Method that calls render function of the renderer with a necessary item meta cast - * @param item - item to be rendered - * @param itemContent - * @param meta + * @param itemContent - content to be rendered in new item + * @param meta - meta used in list item rendering * @returns html element of the rendered item */ renderItem(itemContent: ListItem['content'], meta?: ListItem['meta']): ItemElement { diff --git a/src/index.ts b/src/index.ts index 25b57107..157e5a9b 100644 --- a/src/index.ts +++ b/src/index.ts @@ -67,7 +67,7 @@ export default class NestedList { set listStyle(style: ListDataStyle) { this.data.style = style; - this.changeTabulatorByStyle(style); + this.changeTabulatorByStyle(); /** * Create new list element @@ -145,7 +145,7 @@ export default class NestedList { this.data = data && Object.keys(data).length ? data : initialData; - this.changeTabulatorByStyle(this.defaultListStyle); + this.changeTabulatorByStyle(); } /** @@ -208,10 +208,9 @@ export default class NestedList { } /** - * This method allows changing - * @param style + * This method allows changing tabulator respectfully to passed style */ - changeTabulatorByStyle(style: ListDataStyle) { + changeTabulatorByStyle() { switch (this.listStyle) { case 'ordered': this.list = new ListTabulator({ @@ -266,8 +265,8 @@ export default class NestedList { /** * Convert from list to text for conversionConfig - * @param data - * @returns + * @param data - current data of the list + * @returns - string of the recursively merged contents of the items of the list */ static joinRecursive(data: ListData | ListItem): string { return data.items diff --git a/src/utils/getSiblings.ts b/src/utils/getSiblings.ts index 1464c35c..4cd4d305 100644 --- a/src/utils/getSiblings.ts +++ b/src/utils/getSiblings.ts @@ -1,7 +1,7 @@ /** * Get all siblings before passed element, or after it - * @param element - * @param direction + * @param element - html element whose siblings would be returned + * @param direction - wherever siblings would be returned, after element of before it */ export function getSiblings(element: HTMLElement, direction: 'after' | 'before' = 'after'): Element[] | null { const siblings: Element[] = []; diff --git a/src/utils/itemHasSublist.ts b/src/utils/itemHasSublist.ts index d4299f4a..fcbfdc69 100644 --- a/src/utils/itemHasSublist.ts +++ b/src/utils/itemHasSublist.ts @@ -3,7 +3,7 @@ import { DefaultListCssClasses } from '../ListRenderer'; /** * Check if passed item has the sublist - * @param item + * @param item - item to be checked wherever it has sublist */ export function itemHasSublist(item: ItemElement): boolean { return item.querySelector(`.${DefaultListCssClasses.itemChildren}`) !== null; diff --git a/src/utils/removeChildWrapperIfEmpty.ts b/src/utils/removeChildWrapperIfEmpty.ts index 1638d317..d7e354fc 100644 --- a/src/utils/removeChildWrapperIfEmpty.ts +++ b/src/utils/removeChildWrapperIfEmpty.ts @@ -3,7 +3,7 @@ import { getChildItems } from './getChildItems'; /** * Method that will remove passed child wrapper if it has no child items - * @param childWrapper + * @param childWrapper - childWrapper to be removed if it is empty */ export function removeChildWrapperIfEmpty(childWrapper: ItemChildWrapperElement): void { if (getChildItems(childWrapper) === null) {