Skip to content

Commit

Permalink
update jsdoc descriptions
Browse files Browse the repository at this point in the history
  • Loading branch information
e11sy committed Oct 4, 2024
1 parent 391546c commit c3060e0
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 36 deletions.
3 changes: 1 addition & 2 deletions src/ListRenderer/ChecklistRenderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export class CheckListRenderer implements ListRendererInterface<ChecklistItemMet
/**
* Redners list item element
* @param content - content of the list item
* @param meta
* @param meta - meta of the list item used in rendering of the checklist
* @returns - created html list item element
*/
renderItem(content: string, meta: ChecklistItemMeta): HTMLLIElement {
Expand Down Expand Up @@ -149,7 +149,6 @@ export class CheckListRenderer implements ListRendererInterface<ChecklistItemMet
/**
* Toggle checklist item state
* @param checkbox
* @param event - click
* @returns
*/
private toggleCheckbox(checkbox: Element): void {
Expand Down
4 changes: 2 additions & 2 deletions src/ListRenderer/OrderedListRenderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@ export class OrderedListRenderer implements ListRendererInterface<OrderedListIte
/**
* Redners list item element
* @param content - content of the list item
* @param meta
* @param _meta - meta of the list item unused in rendering of the ordered list
* @returns - created html list item element
*/
renderItem(content: string, meta: OrderedListItemMeta): HTMLLIElement {
renderItem(content: string, _meta: OrderedListItemMeta): HTMLLIElement {
const itemWrapper = Dom.make('li', OrderedListRenderer.CSS.item);
const itemContent = Dom.make('div', OrderedListRenderer.CSS.itemContent, {
innerHTML: content,
Expand Down
4 changes: 2 additions & 2 deletions src/ListRenderer/UnorderedListRenderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@ export class UnorderedListRenderer implements ListRendererInterface<UnorderedLis
/**
* Redners list item element
* @param content - content of the list item
* @param meta
* @param _meta - meta of the list item unused in rendering of the unordered list
* @returns - created html list item element
*/
renderItem(content: string, meta: UnorderedListItemMeta): HTMLLIElement {
renderItem(content: string, _meta: UnorderedListItemMeta): HTMLLIElement {
const itemWrapper = Dom.make('li', UnorderedListRenderer.CSS.item);
const itemContent = Dom.make('div', UnorderedListRenderer.CSS.itemContent, {
innerHTML: content,
Expand Down
30 changes: 11 additions & 19 deletions src/ListTabulator/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ import { OrderedListRenderer } from '../ListRenderer/OrderedListRenderer';
import { UnorderedListRenderer } from '../ListRenderer/UnorderedListRenderer';
import type { NestedListConfig, ListData, ListDataStyle } from '../types/ListParams';
import type { ListItem } from '../types/ListParams';
import type { ItemElement, ItemContentElement, ItemChildWrapperElement } from '../types/Elements';
import type { ItemElement, ItemChildWrapperElement } from '../types/Elements';
import { isHtmlElement } from '../utils/type-guards';
import { getContenteditableSlice, getCaretNodeAndOffset, focus, isCaretAtStartOfInput, save as saveCaret } from '@editorjs/caret';
import { DefaultListCssClasses } from '../ListRenderer';
import type { PasteEvent } from '../types';
import type { API, BlockAPI, PasteConfig } from '@editorjs/editorjs';
import type { ListParams } from '..';
import type { ChecklistItemMeta, OrderedListItemMeta, UnorderedListItemMeta } from '../types/ItemMeta';
import type { ChecklistItemMeta } from '../types/ItemMeta';
import type { ListRenderer } from '../types/ListRenderer';
import { getSiblings } from '../utils/getSiblings';
import { getChildItems } from '../utils/getChildItems';
Expand Down Expand Up @@ -60,8 +60,8 @@ export default class ListTabulator<Renderer extends ListRenderer> {
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();
Expand Down Expand Up @@ -102,7 +102,7 @@ export default class ListTabulator<Renderer extends ListRenderer> {
* 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
Expand Down Expand Up @@ -151,11 +151,8 @@ export default class ListTabulator<Renderer extends ListRenderer> {

/**
* 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) => {
Expand Down Expand Up @@ -329,7 +326,7 @@ export default class ListTabulator<Renderer extends ListRenderer> {

/**
* 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 {
Expand Down Expand Up @@ -480,7 +477,6 @@ export default class ListTabulator<Renderer extends ListRenderer> {
/**
* Reduce indentation for current item
* @param event - keydown
* @returns
*/
shiftTab(event: KeyboardEvent): void {
/**
Expand Down Expand Up @@ -508,8 +504,7 @@ export default class ListTabulator<Renderer extends ListRenderer> {

/**
* Decrease indentation of the passed item
* @param item
* @returns
* @param item - list item to be unshifted
*/
unshiftItem(item: ItemElement): void {
if (!item.parentNode) {
Expand Down Expand Up @@ -691,8 +686,7 @@ export default class ListTabulator<Renderer extends ListRenderer> {
* 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;
Expand Down Expand Up @@ -941,7 +935,6 @@ export default class ListTabulator<Renderer extends ListRenderer> {
/**
* 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;
Expand All @@ -961,9 +954,8 @@ export default class ListTabulator<Renderer extends ListRenderer> {

/**
* 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 {
Expand Down
13 changes: 6 additions & 7 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -145,7 +145,7 @@ export default class NestedList {

this.data = data && Object.keys(data).length ? data : initialData;

this.changeTabulatorByStyle(this.defaultListStyle);
this.changeTabulatorByStyle();
}

/**
Expand Down Expand Up @@ -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<OrderedListRenderer>({
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/utils/getSiblings.ts
Original file line number Diff line number Diff line change
@@ -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[] = [];
Expand Down
2 changes: 1 addition & 1 deletion src/utils/itemHasSublist.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/utils/removeChildWrapperIfEmpty.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit c3060e0

Please sign in to comment.